Package io.jmix.awsfs
Class AwsFileStorage
java.lang.Object
io.jmix.awsfs.AwsFileStorage
- All Implemented Interfaces:
FileStorage
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected Stringprotected intprotected Stringprotected AwsFileStoragePropertiesprotected Stringprotected AtomicReference<software.amazon.awssdk.services.s3.S3Client>protected Stringprotected Stringprotected TimeSource -
Constructor Summary
ConstructorsConstructorDescriptionAwsFileStorage(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 Summary
Modifier 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.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) Saves an InputStream contents into the file storage.voidsetAccessKey(String accessKey) voidvoidsetChunkSize(int chunkSize) voidsetEndpointUrl(String endpointUrl) voidvoidsetSecretAccessKey(String secretAccessKey)
-
Field Details
-
storageName
-
properties
-
accessKey
-
secretAccessKey
-
region
-
bucket
-
chunkSize
protected int chunkSize -
endpointUrl
-
timeSource
-
s3ClientReference
-
-
Constructor Details
-
AwsFileStorage
public AwsFileStorage() -
AwsFileStorage
-
AwsFileStorage
public 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) -
refreshProperties
protected void refreshProperties() -
getAwsCredentialsProvider
protected software.amazon.awssdk.auth.credentials.AwsCredentialsProvider getAwsCredentialsProvider() -
refreshS3Client
public void refreshS3Client() -
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
-
createFileKey
-
createDateDir
-
createUuidFilename
-
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
-
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
-
setAccessKey
-
setSecretAccessKey
-
setRegion
-
setBucket
-
setChunkSize
public void setChunkSize(int chunkSize) -
setEndpointUrl
-