Class TemporaryStorageImpl

java.lang.Object
io.jmix.ui.upload.TemporaryStorageImpl
All Implemented Interfaces:
TemporaryStorage

@Component("ui_TemporaryStorage") public class TemporaryStorageImpl extends Object implements TemporaryStorage
  • Field Details

    • tempFiles

      protected Map<UUID,File> tempFiles
    • BUFFER_SIZE

      protected static final int BUFFER_SIZE
      Upload buffer size. Default: 64 KB
      See Also:
    • tempDir

      protected String tempDir
    • timeSource

      @Autowired protected TimeSource timeSource
    • fileStorageLocator

      @Autowired protected FileStorageLocator fileStorageLocator
  • Constructor Details

    • TemporaryStorageImpl

      public TemporaryStorageImpl()
  • Method Details

    • setCoreProperties

      @Autowired public void setCoreProperties(CoreProperties coreProperties)
    • saveFile

      public UUID saveFile(byte[] data)
      Description copied from interface: TemporaryStorage
      Store the byte array in a new temporary file.
      Specified by:
      saveFile in interface TemporaryStorage
      Parameters:
      data - file contents
      Returns:
      temporary file ID. This ID is cached in memory and can be used for subsequent operations.
    • saveFile

      public UUID saveFile(InputStream stream, TemporaryStorage.UploadProgressListener listener)
      Description copied from interface: TemporaryStorage
      Store the content of stream in a new temporary file.
      Specified by:
      saveFile in interface TemporaryStorage
      Parameters:
      stream - stream which content is to be stored
      listener - optional listener to be notified about storing progress
      Returns:
      temporary file ID. This ID is cached in memory and can be used for subsequent operations.
    • createFile

      public TemporaryStorage.FileInfo createFile()
      Description copied from interface: TemporaryStorage
      Create a new empty temporary file and cache its ID for subsequent operations.
      Specified by:
      createFile in interface TemporaryStorage
      Returns:
      the new temporary file ID
    • createFileInternal

      protected TemporaryStorage.FileInfo createFileInternal()
    • getFile

      public File getFile(UUID fileId)
      Description copied from interface: TemporaryStorage
      Return a previously registered temporary file by its ID.
      Specified by:
      getFile in interface TemporaryStorage
      Parameters:
      fileId - temporary file ID
      Returns:
      temporary file object or null if no file registered under this ID
    • deleteFile

      public void deleteFile(UUID fileId)
      Description copied from interface: TemporaryStorage
      Remove a file from the temporary storage.
      This method is automatically called from putFileIntoStorage() when the file is successfully stored on the middleware.
      Specified by:
      deleteFile in interface TemporaryStorage
      Parameters:
      fileId - temporary file ID
    • deleteFileLink

      public void deleteFileLink(String fileName)
      Description copied from interface: TemporaryStorage
      Remove an entry from the list of currently cached temporary file IDs, if such exists. This method is used by the framework when cleaning up the temp folder.
      Specified by:
      deleteFileLink in interface TemporaryStorage
      Parameters:
      fileName - absolute path to the temporary file
    • putFileIntoStorage

      public FileRef putFileIntoStorage(UUID fileId, String fileName, FileStorage fileStorage)
      Description copied from interface: TemporaryStorage
      Uploads a file from the temporary storage to the FileStorage.
      Specified by:
      putFileIntoStorage in interface TemporaryStorage
      Parameters:
      fileId - temporary file ID
      fileName - file name
      fileStorage - file storage
    • putFileIntoStorage

      public FileRef putFileIntoStorage(UUID fileId, String fileName)
      Description copied from interface: TemporaryStorage
      Uploads a file from the temporary storage to the default FileStorage, which is determined by calling FileStorageLocator.getDefault().
      Specified by:
      putFileIntoStorage in interface TemporaryStorage
      Parameters:
      fileId - temporary file ID
      fileName - file name
    • clearTempDirectory

      public void clearTempDirectory()
    • showTempFiles

      public String showTempFiles()