I have a web page on a web hosting and images are stored on Amazon S3. I want with php be able to download multiple images from Amazon S3 through my web page in a zip file.
我在网络托管上有一个网页,图像存储在Amazon S3上。我想用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. Can I use Amazon lambda?
我所知道的是,无法在S3上压缩文件。我可以使用亚马逊lambda吗?
Best solution I've come across.
我遇到的最佳解决方案。
- The user selects on my website which images they want to downloaded.
-
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主机上的临时目录中。
-
A zip file is created in a temporary directory and a link is sent to the user. After a certain time, I clear up the temporary directory (with a script) on my web host.
在临时目录中创建zip文件,并将链接发送给用户。一段时间后,我在我的网络主机上清理临时目录(带脚本)。
用户在我的网站上选择他们想要下载的图像。
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文件,那将是很好的。
1 个解决方案
#1
1
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. EC2 instances can do this very quickly because they tend to have fast connections to S3.
虽然您可以将对象流式传输到zip文件而不是下载它们,但您已经想出了一个很好的方法。 EC2实例可以非常快速地执行此操作,因为它们往往具有到S3的快速连接。
Lambda doesn't work for this, as it is only triggered when an object is placed into an S3 bucket. You are doing the opposite.
Lambda不适用于此,因为它仅在将对象放入S3存储桶时触发。你正在做相反的事情。
#1
1
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. EC2 instances can do this very quickly because they tend to have fast connections to S3.
虽然您可以将对象流式传输到zip文件而不是下载它们,但您已经想出了一个很好的方法。 EC2实例可以非常快速地执行此操作,因为它们往往具有到S3的快速连接。
Lambda doesn't work for this, as it is only triggered when an object is placed into an S3 bucket. You are doing the opposite.
Lambda不适用于此,因为它仅在将对象放入S3存储桶时触发。你正在做相反的事情。