我想对我的存储桶中 serverless.yml 文件中“public”文件夹中的所有项目启用公共读取访问。
目前这是我用来声明我的存储桶的定义代码。它是从无服务器堆栈示例之一中复制和粘贴的。
Resources:
AttachmentsBucket:
Type: AWS::S3::Bucket
Properties:
AccessControl: PublicRead
# Set the CORS policy
BucketName: range-picker-bucket-${self:custom.stage}
CorsConfiguration:
CorsRules:
-
AllowedOrigins:
- '*'
AllowedHeaders:
- '*'
AllowedMethods:
- GET
- PUT
- POST
- DELETE
- HEAD
MaxAge: 3000
# Print out the name of the bucket that is created
Outputs:
AttachmentsBucketName:
Value:
Ref: AttachmentsBucket
Run Code Online (Sandbox Code Playgroud)
现在,当我尝试对文件使用 url 时,它返回访问被拒绝。我必须在 aws-s3 Web 界面中手动设置每个文件的公共读取权限。
我究竟做错了什么?