上传ZIP文件到S3,使用EC2解压

2021-12-21 00:00:00 amazon-s3 amazon-ec2 php codeigniter

我有一个 Codeigniter 网络应用程序,它每小时向 Amazon S3 上传许多小文件,这导致我的 S3 请求费用非常快.解决此问题的一种方法是压缩文件,将 zip 文件上传到 S3,然后在 S3 上解压缩.

I have a Codeigniter web app that is uploading many tiny files every hour to Amazon S3, which is causing my S3 request charges to shoot up real fast. One way to overcome this will be to zip up the file, upload the zip file to S3, then unzip it when it is on S3.

这可以使用 EC2 完成吗?或者有没有更好的方法来实现这一目标?谢谢!!

Can this be done using EC2? Or is there a better method to achieve this? Thank you!!

如果我要使用 EC2,我是否使用 PHP 来触发 EC2 实例的创建,上传解压缩压缩文件所需的 PHP 文件,将解压缩的文件复制到 S3,然后销毁 EC2 实例?

If I were to use EC2, do I use PHP to trigger the creation of a EC2 instance, upload the PHP file required to unzip the zipped files, copy the uncompressed files to S3, then destroy the EC2 instance?

推荐答案

如果您在同一地区有一台 EC2 机器,我建议您将它上传到压缩包中,然后从那里解压到 s3.S3 无法自行解压缩,因为它完全是静态的.

If you have an EC2 machine in the same region I would suggest you upload it there zipped and then it drop it to s3 from there unzipped. S3 cannot unzip it on its own as its all static.

ec2 和 s3 之间没有任何费用,因此 ec2 可以处理解压缩,然后将其写入您的 s3 存储桶,而无需额外的传输费用.

Theres no charges between ec2 and s3 so ec2 can handle the unzipping and then write it out into your s3 bucket without additional transfer charges.

相关文章