so I've got paperclip set up with uploadify to upload things to S3. I have made my setup so that stuff gets loaded directly to S3 and then when it's done I post to my webserver the results...
所以我用uploadify设置了回形针,将内容上传到S3。我已经进行了设置,以便将内容直接加载到S3,然后在完成后我将结果发布到我的网络服务器...
All I get back is the file name and size. am I supposed to build my own processor or before_post_process method to "download" the file from S3 in order to process it? or am I missing something and uploadify should have provided me a stream with the file inside it after it was done posting to S3?
我得到的只是文件名和大小。我应该构建自己的处理器或before_post_process方法从S3“下载”文件以进行处理吗?或者我错过了什么,uploadify应该在发布到S3之后为我提供了一个包含文件的流?
How do you guys go about direct uploads to S3 and then notifying your paperclip backed model? Do you have to pull files from the server and do post-processing on them or will paperclip handle all of that?
你们如何直接上传到S3,然后通知你的回形针支持的模型?你是否必须从服务器中提取文件并对它们进行后处理或者回形针处理所有这些?
2 个解决方案
#1
8
Here are a couple blog posts describing how to do it...
这里有一些博客文章描述了如何做到这一点......
http://www.railstoolkit.com/posts/uploading-files-directly-to-amazon-s3-using-fancyupload
http://www.railstoolkit.com/posts/fancyupload-amazon-s3-uploader-with-paperclip
They use FancyUploader (which uses MooTools/Flash) to upload directly to S3, bypassing Heroku and their dreaded 30 second request timeout all together, and then use DelayedJob to queue up post-processing tasks like thumbnailing and PaperClip to do the actual processing of the files.
他们使用FancyUploader(使用MooTools / Flash)直接上传到S3,绕过Heroku及其可怕的30秒请求超时,然后使用DelayedJob排队后处理任务,如缩略图和PaperClip来进行实际处理文件。
If I can get this working with CarrierWave, I will post up a project on GitHub to share (in a week or so once I get time)
如果我可以使用CarrierWave,我将在GitHub上发布一个项目进行分享(一旦我有时间,一周左右)
Update:
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
I will add the post-processing example once I have time.
我有时间后会添加后处理示例。
#2
0
You can either create a processor or use the callback methods but the file will definitively be on your server before going to S3.
您可以创建处理器或使用回调方法,但在转到S3之前,文件最终会在您的服务器上。
If you are in the callback method for example you can access it using something like:
例如,如果您使用回调方法,则可以使用以下方法访问它:
self.file.to_file
Once that is done processing and uploading the file will be deleted from your server. You don't need to do anything to notify or post process. Paperclip will handle it.
完成后,处理和上传文件将从您的服务器中删除。您无需做任何事情来通知或发布流程。 Paperclip将处理它。
#1
8
Here are a couple blog posts describing how to do it...
这里有一些博客文章描述了如何做到这一点......
http://www.railstoolkit.com/posts/uploading-files-directly-to-amazon-s3-using-fancyupload
http://www.railstoolkit.com/posts/fancyupload-amazon-s3-uploader-with-paperclip
They use FancyUploader (which uses MooTools/Flash) to upload directly to S3, bypassing Heroku and their dreaded 30 second request timeout all together, and then use DelayedJob to queue up post-processing tasks like thumbnailing and PaperClip to do the actual processing of the files.
他们使用FancyUploader(使用MooTools / Flash)直接上传到S3,绕过Heroku及其可怕的30秒请求超时,然后使用DelayedJob排队后处理任务,如缩略图和PaperClip来进行实际处理文件。
If I can get this working with CarrierWave, I will post up a project on GitHub to share (in a week or so once I get time)
如果我可以使用CarrierWave,我将在GitHub上发布一个项目进行分享(一旦我有时间,一周左右)
Update:
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
I will add the post-processing example once I have time.
我有时间后会添加后处理示例。
#2
0
You can either create a processor or use the callback methods but the file will definitively be on your server before going to S3.
您可以创建处理器或使用回调方法,但在转到S3之前,文件最终会在您的服务器上。
If you are in the callback method for example you can access it using something like:
例如,如果您使用回调方法,则可以使用以下方法访问它:
self.file.to_file
Once that is done processing and uploading the file will be deleted from your server. You don't need to do anything to notify or post process. Paperclip will handle it.
完成后,处理和上传文件将从您的服务器中删除。您无需做任何事情来通知或发布流程。 Paperclip将处理它。