Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/359.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java S3上传中的加密_Java_Encryption_Amazon S3 - Fatal编程技术网

Java S3上传中的加密

Java S3上传中的加密,java,encryption,amazon-s3,Java,Encryption,Amazon S3,在给定代码中: BasicAWSCredentials awsCred = new BasicAWSCredentials(accessKey, secretKey); AmazonS3Client s3Client = new AmazonS3Client(awsCred); TransferManager tm = new TransferManager(s3Client); Upload upload = tm.upload( bucket,key,new File(file)); 如何

在给定代码中:

BasicAWSCredentials awsCred = new BasicAWSCredentials(accessKey, secretKey);
AmazonS3Client s3Client = new AmazonS3Client(awsCred);
TransferManager tm = new TransferManager(s3Client);
Upload upload = tm.upload( bucket,key,new File(file));

如何在上传到s3时添加KMS SSE算法和加密密钥?

从您的代码示例中,我看到您正在使用多部分上传。使用启动多部分上载。创建对象时,可以设置各种加密选项,如和。

以下是多部分上载的加密方法
//加密方法

public static void  addEncryption(InitiateMultipartUploadRequest multipartUploadRequest, String awsKmsEncryptionKey)
{
    ObjectMetadata metadata = new ObjectMetadata();
    metadata.setSSEAlgorithm(SSEAlgorithm.KMS.getAlgorithm());
    multipartUploadRequest.withSSEAwsKeyManagementParams(new SSEAwsKeyManagementParams(awsKmsEncryptionKey));
    multipartUploadRequest.setObjectMetadata(metadata);
}