所以我在Android应用程序中使用AWS S3,将文件上传到S3没有问题,但是当我尝试下载它们时,我收到403错误,拒绝访问。
以下是尝试下载文件的Android代码:
gifFileToShow = new File(gifKey);
TransferObserver s3DownloadObserver = s3TransferUtility.download(
keys.getBucket(),
fileKey,
fileToShow
);
这是我的iAM政策:
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "arn:aws:logs:*:*:*",
"Effect": "Allow"
},
{
"Action": [
"s3:*"
],
"Resource": [
"arn:aws:s3:::mybucket/myfiles/*",
"arn:aws:s3:::mybucket/*"
],
"Effect": "Allow"
},
{
"Condition": {
"StringLike": {
"s3:prefix": [
"myfiles/",
"myfiles/*",
"uploads/",
"uploads/*",
"public/",
"public/*",
"protected/",
"protected/*",
"private/",
"private/*"
]
}
},
"Action": [
"s3:ListBucket",
"elastictranscoder:Read*",
"elastictranscoder:List*",
"elastictranscoder:*Job",
"elastictranscoder:*Preset"
],
"Resource": [
"arn:aws:s3:::mybucket"
],
"Effect": "Allow"
}
]
}
我尝试在"Principal": "*"
下面添加Action": [ "s3:*" ]
,但收到错误:This policy contains the following error: Has prohibited field Principal
有谁知道我做错了什么,或者我能做些什么来解决它?
答案 0 :(得分:1)
您必须允许公开访问才能下载这些文件。