Package io.jmix.localfs
Class LocalFileStorage
java.lang.Object
io.jmix.localfs.LocalFileStorage
- All Implemented Interfaces:
FileStorage
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CorePropertiesstatic final Stringprotected Booleanprotected booleanprotected LocalFileStoragePropertiesprotected Stringprotected Stringprotected Path[]protected TimeSourceprotected ExecutorService -
Constructor Summary
ConstructorsConstructorDescriptionLocalFileStorage(String storageName) LocalFileStorage(String storageName, String storageDir) Optional constructor that allows specifying storage directory, thus overridingLocalFileStorageProperties.getStorageDir()property. -
Method Summary
Modifier 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) Saves an InputStream contents into the file storage.voidsetImmutableFileStorage(boolean immutableFileStorage) This method is mostly needed for compatibility with an old API.protected void
-
Field Details
-
DEFAULT_STORAGE_NAME
- See Also:
-
storageName
-
storageDir
-
properties
-
coreProperties
-
timeSource
-
disablePathCheck
-
isImmutableFileStorage
protected boolean isImmutableFileStorage -
writeExecutor
-
storageRoots
-
-
Constructor Details
-
LocalFileStorage
public LocalFileStorage() -
LocalFileStorage
-
LocalFileStorage
Optional 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
-
getStorageName
Description 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 interfaceFileStorage
-
createUuidFilename
-
getStorageRoots
-
saveStream
-
saveStream
Description copied from interface:FileStorageSaves an InputStream contents into the file storage.- Specified by:
saveStreamin interfaceFileStorage- Parameters:
fileName- file nameinputStream- input stream, must be closed in the calling code- Returns:
- file reference
-
createRelativeFilePath
-
openStream
Description copied from interface:FileStorageReturns an input stream to load a file contents.- Specified by:
openStreamin interfaceFileStorage- Parameters:
reference- file reference- Returns:
- input stream, must be closed after use
-
removeFile
Description copied from interface:FileStorageRemoves a file from the file storage.- Specified by:
removeFilein interfaceFileStorage- Parameters:
reference- file reference
-
fileExists
Description copied from interface:FileStorageTests whether the file denoted by this file reference exists.- Specified by:
fileExistsin interfaceFileStorage- Parameters:
reference- file reference- Returns:
- true if the file denoted by this file reference exists
-
createDateDirPath
-
checkFileExists
-
checkDirectoryExists
-
checkPrimaryStorageAccessible
-
checkStorageDefined
-
setImmutableFileStorage
public 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. -
getRelativePath
Converts string path toPath. -
pathToString
Converts path to a uniform string representation ("yyyy/mm/dd/uuid.ext"). -
stopWriteExecutor
@PreDestroy protected void stopWriteExecutor()
-