开发者

using rails to upload things to s3 with fancyupload

开发者 https://www.devze.com 2022-12-12 16:27 出处:网络
I\'ve been trying to follow this tutorial to let my users upload a bunch of mp3s at once and see the progress.

I've been trying to follow this tutorial to let my users upload a bunch of mp3s at once and see the progress.

http://www.railstoolkit.com/posts/uploading-files-directly-to-amazon-s3-using-fancyupload

I implemented it pretty much more or lese exactly, but I removed some of the things from the policy file, so there's only ['starts-with', '$key', '#{key}/'], instead of the other starts-with stuff which was causing it to fail when I manually put a field and submit into the form.

I also turned on verbose mode. This is what I get when trying to upload a file:

Main::fireEvent "buttonEnter"Swiff.Uploader.js (line 370)
Main::fireEvent "buttonDown"Swiff.Uploader.js (line 370)
Main::fireEvent "buttonEnter"Swiff.Uploader.js (line 370)
Main::fireEvent "browse"Swiff.Uploader.js (line 370)
Main::fireEvent "buttonLeave"Swiff.Uploader.js (line 370)
Main::handleSelect Adding FilesSwiff.Uploader.js (line 370)
Main::hasFile: Checking tarzanandjane.mp3Swiff.Uploader.js (line 370)
Main::fireEvent "select": [[Object id=2 addDate=1259106078359 name=tarzanandjane.mp3 0=Object $family=Object], null, Object uploading=0 bytesLoaded=0 rate=0 size=2891446]Swiff.Uploader.js (line 370)
File[2]::start: ObjectSwiff.Uploader.js (line 370)
Main::fireEvent "fileStart": [Object id=2 addDate=1259106078359 name=tarzanandjane.mp3, Object uploading=1 bytesLoaded=0 rate=0 size=2891446]Swiff.Uploader.js (line 37

What actually happens is that it creates an entry with a stuck progress bar and the correct size of the file, but nothing more seems to happen. I also notice that every time I go to upload a file, I get an error in the net panel of firebug:

ActionController::UnknownAction (No action responded to none. Actions: xxx...):
  C:\Ruby\bin\mongrel_rails:开发者_如何学编程19:in `load'
  C:\Ruby\bin\mongrel_rails:19
  -e:2:in `load'
  -e:2

The really frustrating thing about these problems is that I'm not sure what the best way to go about debugging them is. It's hard for me to see if s3 is complaining about something and silently failing behind the scenes. I can get the URL param string (which looks fine), but that needs to be sent along with a file, so I can't just copy and paste it onto my amazonws file. I've made sure my ACL is very loose and it should pretty much let anyone write anything. As I said before when I put in the fake file field and submit button, they are uploaded to s3. The "none" action is also really annoying because I have no idea what may be causing that in my code. If I could even just get some advice about debugging things like this, that would be great.


The problem origin could be that Flash upload requires a non-empty server response (on mac) and S3 returns only a 201-OK header.

Try to ask the original author of the article in his comment thread, he could have more insight.


Here is a working implementation of that project. Also, if you read the README for my sample app below it will tell you how to debug Flash-based uploaders using WireShark. It's MUCH easier than banging your head against the wall.

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

Here is a different kind of uploader:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消