简体   繁体   English

Paperclip,大文件上传和AWS

[英]Paperclip, large file uploads, and AWS

So, I'm using Paperclip and AWS-S3, which is awesome. 所以,我正在使用Paperclip和AWS-S3,这很棒。 And it works great. 而且效果很好。 Just one problem, though: I need to upload really large files. 但是只有一个问题:我需要上传非常大的文件。 As in over 50 Megabytes. 超过50兆字节。 And so, nginx dies. 所以,nginx死了。 So apparently Paperclip stores things to disk before going to S3? 显然,Paperclip在进入S3之前将东西存储到磁盘上?

I found this really cool article , but it also seems to be going to disk first, and then doing everything else in the background. 我找到了这篇非常酷的文章 ,但它似乎也首先进入磁盘,然后在后台执行其他所有操作。

Ideally, I'd be able to upload the file in the background... I have a small amount of experience doing this with PHP, but nothing with Rails as of yet. 理想情况下,我可以在后台上传文件...我在使用PHP时有很少的经验,但到目前为止Rails没有。 Could anyone point me in a general direction, even? 有人能指出我的大方向吗?

You can bypass the server entirely and upload directly to S3 which will prevent the timeout. 您可以完全绕过服务器并直接上传到S3,这将防止超时。 The same thing happens on Heroku. Heroku也发生了同样的事情。 If you are using Rails 3, please check out my sample projects: 如果您使用的是Rails 3,请查看我的示例项目:

Sample project using Rails 3, Flash and MooTools-based FancyUploader to upload directly to S3: https://github.com/iwasrobbed/Rails3-S3-Uploader-FancyUploader 使用Rails 3,Flash和基于MooTools的FancyUploader直接上传到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 使用Rails 3,Flash / Silverlight / GoogleGears / BrowserPlus和基于jQuery的Plupload的示例项目直接上传到S3: https//github.com/iwasrobbed/Rails3-S3-Uploader-Plupload

By the way, you can do post-processing with Paperclip using something like this blog post (that Nico wrote) describes: 顺便说一下,您可以使用Paperclip进行后期处理,使用类似此博客文章(Nico写的)描述:

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

也许你必须增加ngix配置的超时?

You might be interested in my post here: 您可能对我的帖子感兴趣:

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

Its about uploading multiple files (with progress bars, simultaneously) directly to S3 without hitting the server. 它可以直接向S3上传多个文件(同时带进度条),而无需点击服务器。

I was having a similar problem but with using paperclip, passenger and apache. 我有一个类似的问题,但使用回形针,乘客和阿帕奇。
Like nginx, apache has a Timeout directive in apache which I increased to solve my problem. 像nginx一样,apache在apache中有一个Timeout指令,我增加了它来解决我的问题。

Also there's an interesting thing passenger does when uploading large files. 乘客上传大文件时也会有一件有趣的事情。
Anything over 8k is written to /tmp/passenger. 超过8k的任何东西写入/ tmp / passenger。 and if apache doesn't have permissions to write there you get 500 errors also. 如果apache没有权限写入那里你也会得到500个错误。

Here's the article. 这是文章。
http://tinyw.in/fwVB http://tinyw.in/fwVB

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

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