Package io.jmix.ui.upload
Interface TemporaryStorage
- All Known Implementing Classes:
TemporaryStorageImpl
public interface TemporaryStorage
API for uploading files to the temporary storage.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
static interface
Listener to be notified about the progress of uploading file into the temporary storage. -
Method Summary
Modifier and TypeMethodDescriptionCreate a new empty temporary file and cache its ID for subsequent operations.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.
-
Method Details
-
saveFile
Store the byte array in a new temporary file.- Parameters:
data
- file contents- Returns:
- temporary file ID. This ID is cached in memory and can be used for subsequent operations.
-
saveFile
Store the content of stream in a new temporary file.- 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
TemporaryStorage.FileInfo createFile()Create a new empty temporary file and cache its ID for subsequent operations.- Returns:
- the new temporary file ID
- Throws:
FileStorageException
- in case of IO problems
-
getFile
Return a previously registered temporary file by its ID.- Parameters:
fileId
- temporary file ID- Returns:
- temporary file object or null if no file registered under this ID
-
deleteFile
Remove a file from the temporary storage.
This method is automatically called from putFileIntoStorage() when the file is successfully stored on the middleware.- Parameters:
fileId
- temporary file ID- Throws:
FileStorageException
- in case of IO problems
-
deleteFileLink
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.- Parameters:
fileName
- absolute path to the temporary file
-
putFileIntoStorage
Uploads a file from the temporary storage to the FileStorage.- Parameters:
fileId
- temporary file IDfileName
- file namefileStorage
- file storage
-
putFileIntoStorage
Uploads a file from the temporary storage to the default FileStorage, which is determined by callingFileStorageLocator.getDefault()
.- Parameters:
fileId
- temporary file IDfileName
- file name
-