简体   繁体   中英

Unzip a file an upload all its content to S3 using Rails on Heroku

I am building an API in Rails, and one of the calls will get a zip file containing a static HTML site, upload it to S3, and return the public URL.

What's the best way to approach this? I'm thinking of unzipping the file in Heroku's tmp directory and using s3_uploader to upload all its content on S3.

Is it worth using Carrierwave ?

Nobody answered, so I'll quickly explain how I approached this issue.

I'm using Carrierwave to upload the zip file to S3, and I'm calling the unzip method asynchronously with delayed_job gem. This is pretty well explained on Heroku's dev center page .

The unzip method downloads and extracts the S3 zip file on Heroku's tmp folder, then uploads it back to S3 using the s3_uploader gem. This works quite nicely, the only thing that I have to sort out at some point is deleting the unzipped folder when a model entity gets deleted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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