Package io.jmix.core
Interface FileStorage
- All Known Implementing Classes:
AwsFileStorage
,LocalFileStorage
public interface FileStorage
Interface of a component to store and load files defined by file references.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
fileExists
(FileRef reference) Tests whether the file denoted by this file reference exists.Returns the name of this storage, which will be saved inFileRef
s.openStream
(FileRef reference) Returns an input stream to load a file contents.void
removeFile
(FileRef reference) Removes a file from the file storage.default FileRef
saveStream
(String fileName, InputStream inputStream) Saves an InputStream contents into the file storage.saveStream
(String fileName, InputStream inputStream, Map<String, Object> parameters) Saves an InputStream contents into the file storage using additional parameters.
-
Method Details
-
getStorageName
String getStorageName()Returns the name of this storage, which will be saved inFileRef
s.Each file storage in the application should have a unique name.
-
saveStream
Saves an InputStream contents into the file storage.- Parameters:
fileName
- file nameinputStream
- input stream, must be closed in the calling code- Returns:
- file reference
- Throws:
IllegalArgumentException
- if arguments are incorrectFileStorageException
- if something goes wrong
-
saveStream
Saves an InputStream contents into the file storage using additional parameters.- Parameters:
fileName
- file nameinputStream
- input stream, must be closed in the calling codeparameters
- additional parameters that can be used in specific storage implementation (for example, can be converted to FileRef parameters)- Returns:
- file reference
- Throws:
IllegalArgumentException
- if arguments are incorrectFileStorageException
- if something goes wrong
-
openStream
Returns an input stream to load a file contents.- Parameters:
reference
- file reference- Returns:
- input stream, must be closed after use
- Throws:
IllegalArgumentException
- if arguments are incorrectFileStorageException
- if something goes wrong
-
removeFile
Removes a file from the file storage.- Parameters:
reference
- file reference- Throws:
IllegalArgumentException
- if file reference is invalid
-
fileExists
Tests whether the file denoted by this file reference exists.- Parameters:
reference
- file reference- Returns:
- true if the file denoted by this file reference exists
- Throws:
IllegalArgumentException
- if file reference is invalid
-