AWS开发工具包C ++:将对象放入S3并进行服务器端加密

时间:2016-11-14 06:29:39

标签: c++ amazon-web-services amazon-s3

使用AWS SDK PHP放置对象时,在S3中选择服务器端加密非常容易:

$result = $client->putObject(array(
    'Bucket' => $bucket,
    'Key' => $key,
    'SourceFile' => $source_file,
    'ServerSideEncryption' => 'AES256'
));

使用AWS SDK C ++将对象置于S3中类似于:

Aws::S3::Model::PutObjectRequest object_request;
object_request.WithBucket(bucket_name).WithKey(key_name);
auto input_data = Aws::MakeShared<Aws::FStream>(key_name.c_str(), dir_name.c_str(), std::ios_base::in);
object_request.SetBody(input_data);
auto put_object_outcome = s3_client.PutObject(object_request);

但是,如何使用AWS SDK C ++选择服务器端加密?

2 个答案:

答案 0 :(得分:1)

好的,我找到了解决方案:

object_request.WithServerSideEncryption(Aws::S3::Model::ServerSideEncryption::AES256);

答案 1 :(得分:0)

似乎您正在使用sdk的v1,因此您可以使用WithServerSideEncryptionMethod

来实现此目的
object_request.WithServerSideEncryptionMethod(ServerSideEncryptionMethod.AES256);