根据Amazon S3 documentation我正在尝试使用S3最新的sdk从Android设备上的Amazon S3下载文件内容。
final AmazonS3Client mAmazonS3Client = getS3Client(getAwsDataAccessKey(), getAwsDataSecretKey(), getAwsDataRegion());
// set decryption key
final SSECustomerKey sseCustomerKey = new SSECustomerKey(getPolicySseCustomerKey());
// create request
final GetObjectRequest getObjectRequest = new GetObjectRequest(getAwsDataBucketName(),getPolicyKey())
.withSSECustomerKey(sseCustomerKey);
// download
final S3Object s3Object = mAmazonS3Client.getObject(getObjectRequest);
// get content
objectContent = s3Object.getObjectContent();
然后我得到以下异常:
com.amazonaws.services.s3.model.AmazonS3Exception: Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; Request ID: ...), S3 Extended Request ID: ..
所有凭据都是正确的。
同样,我可以读取未加密的文件
它有什么用?
答案 0 :(得分:0)
解决方案是将getPolicySseCustomerKey()
编码为base64