Package io.jmix.awsfs
Class AwsFileStorage
java.lang.Object
io.jmix.awsfs.AwsFileStorage
- All Implemented Interfaces:
- FileStorage
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected Stringprotected Stringprotected intprotected Stringprotected AwsFileStoragePropertiesprotected Stringprotected AtomicReference<software.amazon.awssdk.services.s3.S3Client>protected Stringprotected Stringprotected TimeSourceprotected boolean
- 
Constructor SummaryConstructorsConstructorDescriptionAwsFileStorage(String storageName) AwsFileStorage(String storageName, String accessKey, String secretAccessKey, String region, String bucket, int chunkSize, String endpointUrl) Optional constructor that allows you to overrideAwsFileStorageProperties.
- 
Method SummaryModifier and TypeMethodDescriptionprotected Stringprotected StringcreateFileKey(String fileName) protected StringcreateUuidFilename(String fileName) booleanfileExists(FileRef reference) Tests whether the file denoted by this file reference exists.protected software.amazon.awssdk.core.sync.RequestBodyfromBytes(byte[] buffer, int length) protected software.amazon.awssdk.auth.credentials.AwsCredentialsProviderReturns the name of this storage, which will be saved inFileRefs.protected voidinitS3Client(org.springframework.boot.context.event.ApplicationStartedEvent event) openStream(FileRef reference) Returns an input stream to load a file contents.protected voidvoidvoidremoveFile(FileRef reference) Removes a file from the file storage.saveStream(String fileName, InputStream inputStream, Map<String, Object> parameters) Saves an InputStream contents into the file storage using additional parameters.voidsetAccessKey(String accessKey) voidvoidsetChunkSize(int chunkSize) voidsetEndpointUrl(String endpointUrl) voidvoidsetSecretAccessKey(String secretAccessKey) voidsetUsePathStyleBucketAddressing(boolean usePathStyleBucketAddressing) Methods 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- 
storageName
- 
properties
- 
accessKey
- 
secretAccessKey
- 
region
- 
bucket
- 
chunkSizeprotected int chunkSize
- 
endpointUrl
- 
usePathStyleBucketAddressingprotected boolean usePathStyleBucketAddressing
- 
timeSource
- 
s3ClientReference
 
- 
- 
Constructor Details- 
AwsFileStoragepublic AwsFileStorage()
- 
AwsFileStorage
- 
AwsFileStoragepublic AwsFileStorage(String storageName, String accessKey, String secretAccessKey, String region, String bucket, int chunkSize, @Nullable String endpointUrl) Optional constructor that allows you to overrideAwsFileStorageProperties.
 
- 
- 
Method Details- 
initS3Client@EventListener protected void initS3Client(org.springframework.boot.context.event.ApplicationStartedEvent event) 
- 
refreshPropertiesprotected void refreshProperties()
- 
getAwsCredentialsProviderprotected software.amazon.awssdk.auth.credentials.AwsCredentialsProvider getAwsCredentialsProvider()
- 
refreshS3Clientpublic void refreshS3Client()
- 
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
 
- 
createFileKey
- 
createDateDir
- 
createUuidFilename
- 
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
 
- 
fromBytesprotected software.amazon.awssdk.core.sync.RequestBody fromBytes(byte[] buffer, int length) 
- 
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
 
- 
setAccessKey
- 
setSecretAccessKey
- 
setRegion
- 
setBucket
- 
setChunkSizepublic void setChunkSize(int chunkSize) 
- 
setEndpointUrl
- 
setUsePathStyleBucketAddressingpublic void setUsePathStyleBucketAddressing(boolean usePathStyleBucketAddressing) 
 
-