简体   繁体   English

从zip文件中从Amazon S3下载多个图像?

[英]Download multiple images from Amazon S3 in a zip file?

I have a web page on a web hosting and images are stored on Amazon S3. 我在虚拟主机上有一个网页,图像存储在Amazon S3上。 I want with php be able to download multiple images from Amazon S3 through my web page in a zip file. 我希望使用php能够通过我的网页以zip文件的形式从Amazon S3下载多个图像。

What are my options and what is the best? 我有什么选择,最好的是什么?

What I know, it is not possible to compress files on S3. 我所知道的,不可能在S3上压缩文件。 Can I use Amazon lambda? 我可以使用Amazon lambda吗?

Best solution I've come across. 我遇到的最好的解决方案。

  1. The user selects on my website which images they want to downloaded. 用户在我的网站上选择要下载的图像。
  2. I get the file name from my database on my web host and download the images from S3 to a temporary directory on my web host. 我从Web主机上的数据库中获取文件名,并将图像从S3下载到Web主机上的临时目录中。

  3. A zip file is created in a temporary directory and a link is sent to the user. 在临时目录中创建一个zip文件,并将链接发送给用户。 After a certain time, I clear up the temporary directory (with a script) on my web host. 一段时间后,我在Web主机上清理了临时目录(使用脚本)。

But it would be great if there are a way that did not go through my hosting to create and download the zip-file. 但是,如果有一种方法不能通过我的托管来创建和下载zip文件,那将是很好的。

AWS S3 is "basic building blocks", so it doesn't support a feature like zipping multiple objects together. AWS S3是“基本构建块”,因此不支持将多个对象压缩在一起的功能。

You've come up with a good method to do it, though you could stream the objects into a zip file rather than downloading them. 尽管您可以将对象流式传输为zip文件,而不是下载它们,但您已经找到了一种很好的方法。 EC2 instances can do this very quickly because they tend to have fast connections to S3. EC2实例可以非常快速地执行此操作,因为它们倾向于与S3建立快速连接。

Lambda doesn't work for this, as it is only triggered when an object is placed into an S3 bucket. Lambda对此不起作用,因为它仅在将对象放入S3存储桶中时才触发。 You are doing the opposite. 您正在相反。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM