Configuring Image Fields

It is possible to view, upload, replace and delete JPG and PNG image files into an entity item. There are two ways of storing a file (configuration is done in the entity class definition):

  • Directly in the database – if a field is marked with @Lob annotation.
  • On the file system – if a String field holding the file path is marked with @FileReference annotation.

Please note that for better performance of image fields processing by LightAdmin, it is advised to enable file streaming in the web.xml of your application as follows:


Configuring Base Directory for Image Fields stored on the File System

If @FileReference annotation is specified with no parameters, the application-wide base directory will be used for the field. The directory is configured in the application’s web.xml as follows:


Alternatively, it is possible to use field-specific directory by specifying it in the baseDirectory parameter of that field’s @FileReference annotation.

The path of the base directory may be absolute or relative to your application.

public class Product {

    private String name;

    private BigDecimal price;

    private byte[] pictureSavedToDatabase;

    @FileReference(baseDirectory = &quot;./fieldSpecificDirectory&quot;)
    private String fileSystemPicture;

    private String fileSystemPictureWithGlobalDirectory;