use of com.amplifyframework.storage.s3.ServerSideEncryption in project amplify-android by aws-amplify.
the class AWSS3StorageUploadFileOperation method start.
@SuppressLint("SyntheticAccessor")
@Override
public void start() {
// Only start if it hasn't already been started
if (transferObserver != null) {
return;
}
// Grab the file to upload...
File file = getRequest().getLocal();
// Set up the metadata
ObjectMetadata objectMetadata = new ObjectMetadata();
objectMetadata.setUserMetadata(getRequest().getMetadata());
objectMetadata.setContentType(getRequest().getContentType());
ServerSideEncryption storageServerSideEncryption = getRequest().getServerSideEncryption();
if (!ServerSideEncryption.NONE.equals(storageServerSideEncryption)) {
objectMetadata.setSSEAlgorithm(storageServerSideEncryption.getName());
}
// Upload!
awsS3StoragePluginConfiguration.getAWSS3PluginPrefixResolver(cognitoAuthProvider).resolvePrefix(getRequest().getAccessLevel(), getRequest().getTargetIdentityId(), prefix -> {
try {
String serviceKey = prefix.concat(getRequest().getKey());
transferObserver = storageService.uploadFile(serviceKey, file, objectMetadata);
transferObserver.setTransferListener(new UploadTransferListener());
} catch (Exception exception) {
onError.accept(new StorageException("Issue uploading file.", exception, "See included exception for more details and suggestions to fix."));
}
}, onError);
}
use of com.amplifyframework.storage.s3.ServerSideEncryption in project amplify-android by aws-amplify.
the class AWSS3StorageUploadInputStreamOperation method start.
@SuppressLint("SyntheticAccessor")
@Override
public void start() {
// Only start if it hasn't already been started
if (transferObserver != null) {
return;
}
// Grab the inputStream to upload...
InputStream inputStream = getRequest().getLocal();
// Set up the metadata
ObjectMetadata objectMetadata = new ObjectMetadata();
objectMetadata.setUserMetadata(getRequest().getMetadata());
objectMetadata.setContentType(getRequest().getContentType());
ServerSideEncryption storageServerSideEncryption = getRequest().getServerSideEncryption();
if (!ServerSideEncryption.NONE.equals(storageServerSideEncryption)) {
objectMetadata.setSSEAlgorithm(storageServerSideEncryption.getName());
}
awsS3StoragePluginConfiguration.getAWSS3PluginPrefixResolver(cognitoAuthProvider).resolvePrefix(getRequest().getAccessLevel(), getRequest().getTargetIdentityId(), prefix -> {
try {
String serviceKey = prefix.concat(getRequest().getKey());
transferObserver = storageService.uploadInputStream(serviceKey, inputStream, objectMetadata);
transferObserver.setTransferListener(new UploadTransferListener());
} catch (IOException ioException) {
onError.accept(new StorageException("Issue uploading inputStream.", ioException, "See included exception for more details and suggestions to fix."));
}
}, onError);
}
Aggregations