Package io.jmix.awsfs
Class AwsFileStorage
java.lang.Object
io.jmix.awsfs.AwsFileStorage
- All Implemented Interfaces:
FileStorage
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
protected String
protected int
protected String
protected AwsFileStorageProperties
protected String
protected AtomicReference<software.amazon.awssdk.services.s3.S3Client>
protected String
protected String
protected TimeSource
-
Constructor Summary
ConstructorDescriptionAwsFileStorage
(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 String
protected String
createFileKey
(String fileName) protected String
createUuidFilename
(String fileName) boolean
fileExists
(FileRef reference) Tests whether the file denoted by this file reference exists.protected software.amazon.awssdk.auth.credentials.AwsCredentialsProvider
Returns the name of this storage, which will be saved inFileRef
s.protected void
initS3Client
(org.springframework.boot.context.event.ApplicationStartedEvent event) openStream
(FileRef reference) Returns an input stream to load a file contents.protected void
void
void
removeFile
(FileRef reference) Removes a file from the file storage.saveStream
(String fileName, InputStream inputStream) Saves an InputStream contents into the file storage.void
setAccessKey
(String accessKey) void
void
setChunkSize
(int chunkSize) void
setEndpointUrl
(String endpointUrl) void
void
setSecretAccessKey
(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:FileStorage
Returns the name of this storage, which will be saved inFileRef
s.Each file storage in the application should have a unique name.
- Specified by:
getStorageName
in interfaceFileStorage
-
createFileKey
-
createDateDir
-
createUuidFilename
-
saveStream
Description copied from interface:FileStorage
Saves an InputStream contents into the file storage.- Specified by:
saveStream
in interfaceFileStorage
- Parameters:
fileName
- file nameinputStream
- input stream, must be closed in the calling code- Returns:
- file reference
-
openStream
Description copied from interface:FileStorage
Returns an input stream to load a file contents.- Specified by:
openStream
in interfaceFileStorage
- Parameters:
reference
- file reference- Returns:
- input stream, must be closed after use
-
removeFile
Description copied from interface:FileStorage
Removes a file from the file storage.- Specified by:
removeFile
in interfaceFileStorage
- Parameters:
reference
- file reference
-
fileExists
Description copied from interface:FileStorage
Tests whether the file denoted by this file reference exists.- Specified by:
fileExists
in 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
-