AWS S3物件無法下載——This XML file does not appear to have any style information associated with it
阿新 • • 發佈:2019-01-25
最近,需要從AWS S3上下載渲染後的圖片,遇到了如下問題:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error> <Code>AccessDenied</Code> <Message>Access Denied</Message> <RequestId>9695588FE619D9CA</RequestId> <HostId> +Kce7U7E7J1gdbrZVjgsoasJauHiIFxwVqRkLXPsg0kezaJvzI92U/3Ao2N1XwiqNdv1UEhSBTo= </HostId> </Error>
原因是上傳到S3的檔案預設是私有的。
如果通過AWS控制檯進行下載,可以選中該檔案,選擇“公開”,之後就有下載許可權了。如下所示:
如果想要預設情況下公開某儲存桶中的部分或全部內容,需要設定儲存桶策略。如下所示:
點選上述連結,進入如下介面進行相關設定:
設定完成後,點選會生成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欄位複製到編輯器中儲存即可。