上传&通过Heroku托管的Rails将文件解压缩到S3? [英] Uploading & Unzipping files to S3 through Rails hosted on Heroku?

查看:92
本文介绍了上传&通过Heroku托管的Rails将文件解压缩到S3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够将zip文件上传到包含大量图像的Rails应用程序。然后,我希望Rails解压缩该文件,并通过 Paperclip 将内部图像添加到我的照片模型中,如此它们最终存储在我的Amazon S3帐户(通过Paperclip配置)中。



我想在我的Rails站点上执行此操作,该站点位于 Heroku ,不幸的是它不允许任何类型的本地存储(据我所知)暂时在Paperclip解析之前进行解压缩。

我该怎么做?

建议直接上传到S3,完全绕过Heroku,这样你就不会受限于他们强制执行的30秒请求超时(这会导致你在上次下载后上传)或1gb / tmp

使用Rails 3,Flash的示例项目和基于MooTools的FancyUploader直接上传到S3: https://github.com/iwasrobbed/ Rails3-S3-Uploader-FancyUploader



使用Rails 3,Flash / Silverlight / GoogleGears / BrowserPlus和基于jQuery的Plupload直接上传到S3的示例项目: https://github.com/iwasrobbed/Rails3-S3-Uploader-Plupload



以下是Paperclip后期处理图片链接的例子:

http://www.railstoolkit.com/posts/fancyupload-amazon-s3-uploader-与-纸夹


I'd like to be able to upload a zip file to my Rails application that contains a number of images. Then I'd like Rails to unzip that file and attach the images inside to my Photo's model via Paperclip, so that they are ultimately stored on my Amazon S3 account (configured through Paperclip).

I'd like do do this all on my Rails site hosted on Heroku, which unfortunately doesn't allow local storage of any kind (so far as I'm aware) to temporarily do the unzipping before the Paperclip parsing.

How would I do this??

解决方案

I would recommend uploading directly to S3 which bypasses Heroku entirely so you're not restricted to the 30 second request timeout they enforce (which drops your uploads after that time is hit) or the 1gb /tmp directory limit. After the file is uploaded, you can make a POST to your Rails app with the file's name and location and then do your unzipping operation. If you'd like to use Paperclip for post-processing, I have attached a link below. If you end up going the route of uploading directly to S3 which offloads the work from your Rails server, please check out my sample projects:

Sample project using Rails 3, Flash and MooTools-based FancyUploader to upload directly to S3: https://github.com/iwasrobbed/Rails3-S3-Uploader-FancyUploader

Sample project using Rails 3, Flash/Silverlight/GoogleGears/BrowserPlus and jQuery-based Plupload to upload directly to S3: https://github.com/iwasrobbed/Rails3-S3-Uploader-Plupload

Here is the link for the Paperclip post processing for an example like images:

http://www.railstoolkit.com/posts/fancyupload-amazon-s3-uploader-with-paperclip

这篇关于上传&通过Heroku托管的Rails将文件解压缩到S3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆