为了在 S3 中复制文件,我正在使用vfs-s3-2.2.1.jar我发现S3文件对象班级下com.intridea.io.vfs.provider.s3包裹。
我正在其中使用public void copyFrom(final FileObject file, final FileSelector selector)
复制文件的方法。
在这个方法中我发现了以下代码:
try {
if (srcFile.getType().hasChildren()) {
destFile.createFolder();
// do server side copy if both source and dest are in S3 and using same credentials
} else if (srcFile instanceof S3FileObject) {
S3FileObject s3SrcFile = (S3FileObject)srcFile;
String srcBucketName = s3SrcFile.getBucket().getName();
String srcFileName = s3SrcFile.getS3Key();
String destBucketName = destFile.getBucket().getName();
String destFileName = destFile.getS3Key();
CopyObjectRequest copy = new CopyObjectRequest(
srcBucketName, srcFileName, destBucketName, destFileName);
if (srcFile.getType() == FileType.FILE && getServerSideEncryption()) {
ObjectMetadata meta = s3SrcFile.getObjectMetadata();
meta.setSSEAlgorithm(AES_256_SERVER_SIDE_ENCRYPTION);
copy.setNewObjectMetadata(meta);
}
getService().copyObject(copy);
} else if (srcFile.getType().hasContent() && srcFile.getURL().getProtocol().equals("file")) {
// do direct upload from file to avoid overhead of making a copy of the file
try {
File localFile = new File(srcFile.getURL().toURI());
destFile.upload(localFile);
} catch (URISyntaxException e) {
// couldn't convert URL to URI, but should still be able to do the slower way
super.copyFrom(file, selector);
}
} else {
super.copyFrom(file, selector);
}
} catch (IOException e) {
throw new FileSystemException("vfs.provider/copy-file.error", new Object[]{srcFile, destFile}, e);
} catch (AmazonClientException e) {
throw new FileSystemException("vfs.provider/copy-file.error", new Object[]{srcFile, destFile}, e);
} finally {
destFile.close();
}
在官方参考中它使用这些方法 http://docs.aws.amazon.com/AmazonS3/latest/dev/sse-c-using-java-sdk.html
withSourceSSECustomerKey(sseKey)
withDestinationSSECustomerKey(newSseKey);
In copyFrom的方法vfs-s3-2.2.1.jar S3文件对象我找不到任何设置方法上交所客户密钥我怎样才能达到同样的效果。
感谢您看到这里。