简体   繁体   English

可以授予对我的 Amazon S3 存储桶中某些对象的公共读取访问权限吗?

[英]is it okay grant public read access to some objects in my Amazon S3 bucket?

I store profile pictures in the s3 bucket and I store the aws URL in my database.我将个人资料图片存储在 s3 存储桶中,并将 aws URL 存储在我的数据库中。 when I need the profile picture I set the URL in the database into image tag.for this I set s3 bucket policy as public for read access.is this is a good idea or is there any other way to do this?当我需要个人资料图片时,我将数据库中的 URL 设置为图像标签。为此,我将 s3 存储桶策略设置为公开以进行读取访问。这是一个好主意还是有其他方法可以做到这一点?

One way of going around making a bucket publicly accessible is to:使存储桶可公开访问的一种方法是:

  • put all your image files under one 'folder'将所有图像文件放在一个“文件夹”下
  • create a CloudFront Distribution that serves only from that folder创建仅从该文件夹提供服务的 CloudFront 分配
  • only allow read access to the Identity that will be generated by the CF wizard只允许对将由 CF 向导生成的身份进行读取访问

On the back end you should be able to infer the final location of the assets, as you should know the CF endpoint at this point.在后端,您应该能够推断出资产的最终位置,因为此时您应该知道 CF 端点。

Note: you should set the CF endpoint as an env var for your backend and not hardcode it.注意:您应该将 CF 端点设置为后端的环境变量,而不是对其进行硬编码。

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

相关问题 Amazon S3 存储桶策略公开 - Amazon S3 Bucket Policy Public 如何让我的 HTML 文件访问 Amazon S3 存储桶中的 CSS 和 JavaScript 文件? - How can I get my HTML file to access my CSS and JavaScript files in an Amazon S3 Bucket? 如何显示不公开的s3存储桶中的对象 - How to show objects from an s3 bucket that is not public Amazon S3 base64 尽管存储桶是公共的,但图像不适用于 og:image 标签 - Amazon S3 base64 Image is not working on og:image tags though bucket is public 当存储桶设置为公共时,IAM用户只能访问S3存储桶 - IAM user can only access S3 bucket when bucket is set to public 使用 promise 从 s3 存储桶(min.io 或 amazon)中获取对象列表 - Get list of objects from s3 bucket (min.io or amazon) using promise 使用Node.js读取上传到Amazon s3存储桶的文件的内容 - Read the contents of a file uploaded to an amazon s3 bucket with Node.js 如何在没有 Aws 密钥和秘密的情况下从 S3 公共存储桶读取 zip 文件 - How to read zip file from S3 public bucket without Aws key and secret 使用 CDK 创建可以读取非公共 S3 存储桶的 API 网关 - Create API Gateway that can read non-public S3 bucket using CDK 如何在不直接访问存储桶的情况下下载存储在 Amazon S3 上的资产(zip 文件) - How to download an asset (zip file) stored on Amazon S3 without having direct access to the bucket
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM