我正在尝试从 S3 读取加密对象,然后将其上传到 S3 中具有不同加密密钥的新存储桶。当我尝试读取对象时,使用getObject()并尝试使用PutObject请求放置对象。
当我打印源的内容长度时,它是964481376。那么,数据长度来自哪里呢?这是964481363
我的源文件的元数据如下所示:
内容类型
二进制/八进制流
x-amz-meta-x-amz-unencrypted-content-length
964481363
x-amz-meta-x-amz-wrap-alg
公里
我无法共享 KMS 密钥。
public boolean copyS3Object(AmazonS3Encryption sourceS3Client, AmazonS3URI sourceS3Uri,
AmazonS3Encryption destS3Client, AmazonS3URI destS3Uri) throws AmazonServiceException, IOException {
//String eTag;
S3Object sourceS3Object = null;
try {
//Get the Source object stream
sourceS3Object = sourceS3Client.getObject(sourceS3Uri.getBucket(), sourceS3Uri.getKey());
ObjectMetadata objectMetadata = sourceS3Object.getObjectMetadata();
System.out.println("content length " + objectMetadata.getContentLength());
PutObjectRequest putRequest = new PutObjectRequest(destS3Uri.getBucket(), destS3Uri.getKey(),
sourceS3Object.getObjectContent(), sourceS3Object.getObjectMetadata());
destS3Client.putObject(putRequest);
//
// if (eTag.isEmpty()) {
// System.out.println("Copy failed, New object in " + destS3Uri.toString() + " is empty");
// return false;
// }
} catch (AmazonServiceException e) {
throw e;
} finally {
if (sourceS3Object != null) {
sourceS3Object.close();
}
}
//System.out.println("Copied successfully to " + destS3Uri.toString() + " Etag:" + eTag);
return true;
}
蛊毒传说
相关分类