AWS S3对象无法下载——This XML file does not appear to have any style information associated with it

最近,需要从AWS S3上下载渲染后的图片,遇到了如下问题:


This XML file does not appear to have any style information associated with it. The document tree is shown below.


AccessDenied
Access Denied
9695588FE619D9CA

+Kce7U7E7J1gdbrZVjgsoasJauHiIFxwVqRkLXPsg0kezaJvzI92U/3Ao2N1XwiqNdv1UEhSBTo=


原因是上传到S3的文件默认是私有的。

如果通过AWS控制台进行下载,可以选中该文件,选择“公开”,之后就有下载权限了。如下所示:

AWS S3对象无法下载——This XML file does not appear to have any style information associated with it_第1张图片

如果想要默认情况下公开某存储桶中的部分或全部内容,需要设置存储桶策略。如下所示:

https://awspolicygen.s3.cn-north-1.amazonaws.com.cn/policygen.html

点击上述链接,进入如下界面进行相关设置:

AWS S3对象无法下载——This XML file does not appear to have any style information associated with it_第2张图片

设置完成后,点击会生成json格式的存储桶策略:

{
  "Id": "Policy1512913721966",
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Stmt1512913719687",
      "Action": [
        "s3:GetObject"
      ],
      "Effect": "Allow",
      "Resource": "arn:aws-cn:s3:::bucket-my",
      "Principal": "*"
    }
  ]
}

接着打开AWS S3控制台,在待设置的存储桶“权限”中选择“存储桶策略”,将上面json字段复制到编辑器中保存即可。

AWS S3对象无法下载——This XML file does not appear to have any style information associated with it_第3张图片





你可能感兴趣的:(AWS)