使用AWS SDK,可以像这样轻松实现:
PutObjectRequest putRequest =
new PutObjectRequest(bucket_name, bucket_name, new File(file_path))
.withSSEAwsKeyManagementParams(new SSEAwsKeyManagementParams("KMS-KEY"));
s3.putObject(putRequest);
但是,这可以使用spring-cloud-aws和s3支持的ResourceLoader实现吗?
WritableResource resource = (WritableResource) resourceLoader
.getResource(s3Url);
try (OutputStream outputStream = resource.getOutputStream()) {
Files.copy(file.toPath(), outputStream);
}
目前还不可行。现在已经创建了一个功能请求:https://github.com/spring-cloud/spring-cloud-aws/issues/104