简体   繁体   English

AmazonS3Exception:拒绝访问S3

[英]AmazonS3Exception: Access Denied S3

According to Amazon S3 documentation I'm trying to download file content from Amazon S3 on Android device using the S3 latest sdk. 根据Amazon S3文档,我正尝试使用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();

Then I'm getting the following exception: 然后我得到以下异常:

com.amazonaws.services.s3.model.AmazonS3Exception: Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; Request ID: ...), S3 Extended Request ID: ..

All the credentials are correct. 所有凭据均正确。
Also in the same way I can read not encrypted file. 同样,我可以读取未加密的文件。
What can it be? 会是什么

解决方案是将getPolicySseCustomerKey()编码为base64

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM