Package io.jmix.flowui.upload
Class TemporaryStorageImpl
java.lang.Object
io.jmix.flowui.upload.TemporaryStorageImpl
- All Implemented Interfaces:
TemporaryStorage
@Component("flowui_TemporaryStorage")
public class TemporaryStorageImpl
extends Object
implements TemporaryStorage
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.jmix.flowui.upload.TemporaryStorage
TemporaryStorage.FileInfo, TemporaryStorage.UploadProgressListener
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final int
Upload buffer size.protected FileStorageLocator
protected String
protected TimeSource
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Create a new empty temporary file and cache its ID for subsequent operations.protected TemporaryStorage.FileInfo
void
deleteFile
(UUID fileId) Remove a file from the temporary storage.void
deleteFileLink
(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.void
setCoreProperties
(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:TemporaryStorage
Store the byte array in a new temporary file.- Specified by:
saveFile
in 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:TemporaryStorage
Store the content of stream in a new temporary file.- Specified by:
saveFile
in 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:TemporaryStorage
Create a new empty temporary file and cache its ID for subsequent operations.- Specified by:
createFile
in interfaceTemporaryStorage
- Returns:
- the new temporary file ID
-
createFileInternal
-
getFile
Description copied from interface:TemporaryStorage
Return a previously registered temporary file by its ID.- Specified by:
getFile
in interfaceTemporaryStorage
- Parameters:
fileId
- temporary file ID- Returns:
- temporary file object or null if no file registered under this ID
-
deleteFile
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 interfaceTemporaryStorage
- Parameters:
fileId
- temporary file ID
-
deleteFileLink
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 interfaceTemporaryStorage
- Parameters:
fileName
- absolute path to the temporary file
-
putFileIntoStorage
Description copied from interface:TemporaryStorage
Uploads a file from the temporary storage to the FileStorage.- Specified by:
putFileIntoStorage
in interfaceTemporaryStorage
- Parameters:
fileId
- temporary file IDfileName
- file namefileStorage
- file storage
-
putFileIntoStorage
Description copied from interface:TemporaryStorage
Uploads a file from the temporary storage to the default FileStorage, which is determined by callingFileStorageLocator.getDefault()
.- Specified by:
putFileIntoStorage
in interfaceTemporaryStorage
- Parameters:
fileId
- temporary file IDfileName
- file name
-
clearTempDirectory
public void clearTempDirectory() -
showTempFiles
-