Package io.jmix.ui.upload
Class TemporaryStorageImpl
java.lang.Object
io.jmix.ui.upload.TemporaryStorageImpl
- All Implemented Interfaces:
TemporaryStorage
@Component("ui_TemporaryStorage")
public class TemporaryStorageImpl
extends Object
implements TemporaryStorage
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.jmix.ui.upload.TemporaryStorage
TemporaryStorage.FileInfo, TemporaryStorage.UploadProgressListener -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intUpload buffer size.protected FileStorageLocatorprotected Stringprotected TimeSource -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCreate a new empty temporary file and cache its ID for subsequent operations.protected TemporaryStorage.FileInfovoiddeleteFile(UUID fileId) Remove a file from the temporary storage.voiddeleteFileLink(String fileName) Remove an entry from the list of currently cached temporary file IDs, if such exists.Return a previously registered temporary file by its ID.putFileIntoStorage(UUID fileId, String fileName) Uploads a file from the temporary storage to the default FileStorage, which is determined by callingFileStorageLocator.getDefault().putFileIntoStorage(UUID fileId, String fileName, FileStorage fileStorage) Uploads a file from the temporary storage to the FileStorage.saveFile(byte[] data) Store the byte array in a new temporary file.saveFile(InputStream stream, TemporaryStorage.UploadProgressListener listener) Store the content of stream in a new temporary file.voidsetCoreProperties(CoreProperties coreProperties)
-
Field Details
-
tempFiles
-
BUFFER_SIZE
protected static final int BUFFER_SIZEUpload buffer size. Default: 64 KB- See Also:
-
tempDir
-
timeSource
-
fileStorageLocator
-
-
Constructor Details
-
TemporaryStorageImpl
public TemporaryStorageImpl()
-
-
Method Details
-
setCoreProperties
-
saveFile
Description copied from interface:TemporaryStorageStore the byte array in a new temporary file.- Specified by:
saveFilein interfaceTemporaryStorage- Parameters:
data- file contents- Returns:
- temporary file ID. This ID is cached in memory and can be used for subsequent operations.
-
saveFile
Description copied from interface:TemporaryStorageStore the content of stream in a new temporary file.- Specified by:
saveFilein interfaceTemporaryStorage- Parameters:
stream- stream which content is to be storedlistener- 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
Description copied from interface:TemporaryStorageCreate a new empty temporary file and cache its ID for subsequent operations.- Specified by:
createFilein interfaceTemporaryStorage- Returns:
- the new temporary file ID
-
createFileInternal
-
getFile
Description copied from interface:TemporaryStorageReturn a previously registered temporary file by its ID.- Specified by:
getFilein interfaceTemporaryStorage- Parameters:
fileId- temporary file ID- Returns:
- temporary file object or null if no file registered under this ID
-
deleteFile
Description copied from interface:TemporaryStorageRemove a file from the temporary storage.
This method is automatically called from putFileIntoStorage() when the file is successfully stored on the middleware.- Specified by:
deleteFilein interfaceTemporaryStorage- Parameters:
fileId- temporary file ID
-
deleteFileLink
Description copied from interface:TemporaryStorageRemove 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:
deleteFileLinkin interfaceTemporaryStorage- Parameters:
fileName- absolute path to the temporary file
-
putFileIntoStorage
Description copied from interface:TemporaryStorageUploads a file from the temporary storage to the FileStorage.- Specified by:
putFileIntoStoragein interfaceTemporaryStorage- Parameters:
fileId- temporary file IDfileName- file namefileStorage- file storage
-
putFileIntoStorage
Description copied from interface:TemporaryStorageUploads a file from the temporary storage to the default FileStorage, which is determined by callingFileStorageLocator.getDefault().- Specified by:
putFileIntoStoragein interfaceTemporaryStorage- Parameters:
fileId- temporary file IDfileName- file name
-
clearTempDirectory
public void clearTempDirectory() -
showTempFiles
-