Package io.jmix.localfs
Class LocalFileStorage
java.lang.Object
io.jmix.localfs.LocalFileStorage
- All Implemented Interfaces:
- FileStorage
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected CorePropertiesstatic final Stringprotected booleanprotected LocalFileStoragePropertiesprotected Stringprotected Stringprotected Path[]protected TimeSourceprotected ExecutorService
- 
Constructor SummaryConstructorsConstructorDescriptionLocalFileStorage(String storageName) LocalFileStorage(String storageName, String storageDir) Optional constructor that allows specifying storage directory, thus overridingLocalFileStorageProperties.getStorageDir()property.
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidcheckDirectoryExists(Path dir) protected voidcheckFileExists(Path path) protected voidcheckPrimaryStorageAccessible(Path[] roots, String fileName) protected voidcheckStorageDefined(Path[] roots, String fileName) protected Pathprotected PathcreateRelativeFilePath(String fileName) protected StringcreateUuidFilename(String fileName) booleanfileExists(FileRef reference) Tests whether the file denoted by this file reference exists.protected PathgetRelativePath(String path) Converts string path toPath.Returns the name of this storage, which will be saved inFileRefs.protected Path[]openStream(FileRef reference) Returns an input stream to load a file contents.protected StringpathToString(Path path) Converts path to a uniform string representation ("yyyy/mm/dd/uuid.ext").voidremoveFile(FileRef reference) Removes a file from the file storage.longsaveStream(FileRef fileRef, InputStream inputStream) saveStream(String fileName, InputStream inputStream, Map<String, Object> parameters) Saves an InputStream contents into the file storage using additional parameters.voidsetImmutableFileStorage(boolean immutableFileStorage) This method is mostly needed for compatibility with an old API.protected voidMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.jmix.core.FileStoragesaveStream
- 
Field Details- 
DEFAULT_STORAGE_NAME- See Also:
 
- 
storageName
- 
storageDir
- 
properties
- 
coreProperties
- 
timeSource
- 
isImmutableFileStorageprotected boolean isImmutableFileStorage
- 
writeExecutor
- 
storageRoots
 
- 
- 
Constructor Details- 
LocalFileStoragepublic LocalFileStorage()
- 
LocalFileStorage
- 
LocalFileStorageOptional constructor that allows specifying storage directory, thus overridingLocalFileStorageProperties.getStorageDir()property.It can be useful if there are more than one local file storage in an application, and these storages should be using different dirs for storing files. 
 
- 
- 
Method Details- 
getStorageNameDescription copied from interface:FileStorageReturns the name of this storage, which will be saved inFileRefs.Each file storage in the application should have a unique name. - Specified by:
- getStorageNamein interface- FileStorage
 
- 
createUuidFilename
- 
getStorageRoots
- 
saveStream
- 
saveStreamDescription copied from interface:FileStorageSaves an InputStream contents into the file storage using additional parameters.- Specified by:
- saveStreamin interface- FileStorage
- Parameters:
- fileName- file name
- inputStream- input stream, must be closed in the calling code
- parameters- additional parameters that can be used in specific storage implementation (for example, can be converted to FileRef parameters)
- Returns:
- file reference
 
- 
createRelativeFilePath
- 
openStreamDescription copied from interface:FileStorageReturns an input stream to load a file contents.- Specified by:
- openStreamin interface- FileStorage
- Parameters:
- reference- file reference
- Returns:
- input stream, must be closed after use
 
- 
removeFileDescription copied from interface:FileStorageRemoves a file from the file storage.- Specified by:
- removeFilein interface- FileStorage
- Parameters:
- reference- file reference
 
- 
fileExistsDescription copied from interface:FileStorageTests whether the file denoted by this file reference exists.- Specified by:
- fileExistsin interface- FileStorage
- Parameters:
- reference- file reference
- Returns:
- true if the file denoted by this file reference exists
 
- 
createDateDirPath
- 
checkFileExists
- 
checkDirectoryExists
- 
checkPrimaryStorageAccessible
- 
checkStorageDefined
- 
setImmutableFileStoragepublic void setImmutableFileStorage(boolean immutableFileStorage) This method is mostly needed for compatibility with an old API.If isImmutableFileStorageis false thensaveStream(FileRef, InputStream)will be overwriting existing files.
- 
getRelativePathConverts string path toPath.
- 
pathToStringConverts path to a uniform string representation ("yyyy/mm/dd/uuid.ext").
- 
stopWriteExecutor@PreDestroy protected void stopWriteExecutor()
 
-