Amazon S3私有存储桶显示许多用户图像

发布于 2025-01-30 05:49:40 字数 601 浏览 3 评论 0原文

我正在尝试找出显示许多私人用户图像的最佳方法。我正在建立一个Instagram克隆作为练习应用程序,以学习S3和其他AWS服务。

使用预签名的URL显示从私有S3存储桶中显示单个图像的教程,但我找不到资源大规模地执行此操作。

问题:

1a。 如果我正在创建一个缩略图的照片库,一次将20-50(或更多)图像删除,这是否意味着我需要为每个图像提出20-50+预先签名的URL请求?每个图像提出一个请求似乎很多。

1b。 如果我确实必须创建预签名的URL,那最好在前端或后端执行此操作? AWS SDK允许双方完成此操作,但是哪种方法最好?

1c。 最后,如果创建预先签名的URL是处理此问题的最佳方法,那么到期长度和缓存图像的最佳实践是什么?关于Instagram或其他流行的图像共享网站如何将其访问的任何想法吗?

我发现的预签名URL的替代解决方案:

2。 为后端创建IAM角色,请从S3下载私人图像,然后将其提供到前端。这似乎是一个昂贵的操作,但我发现的唯一选择。

I am trying to figure out the best way to display many private user images. I am building an Instagram clone as a practice app to learn S3 and other AWS services.

There are many tutorials on displaying a single image from a private s3 bucket using pre-signed URLs but I can't find resources to do this at scale.

Questions:

1A.
If I am creating a photo gallery of thumbnails that pulls down 20-50 (or more) images at a time, does that mean I need to make 20-50+ pre-signed URL requests for each of those images? Making one request per image just seems like a lot.

1B.
If I do have to create pre-signed URLs is it best to do this on the frontend or backend? AWS SDK allows for this to be done on either side but which approach is best?

1C.
Lastly, if creating pre-signed URLs is the best way to approach this, what are best practices for expiration length and caching images? Any idea on how Instagram or other popular image sharing websites approach this?

Alternative solution to pre-signed URLs that I've found:

2.
Create an IAM role for the backend, have the BE download the private images from s3 then serve them to the front end. This seems like an expensive operation but the only alternative I found.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文