Ruby on Rails Sunday, August 1, 2010

Hi,

I am developping a small Flash app to upload multiple files with a
progress bar in a Rails site.

Rails handles the server side. I have a controller that displays the
view containing the flash, and it also provides a security token to the
flash. The Flash gets it and send it back to the server in the HTTP
request that contains the file to upload.

Big surprise : it works perfectly in Internet Explorer... but not in
Firefox nor in Opera. :S

For Firefox and Opera, I get a
ActionController::InvalidAuthenticityToken in the console.

I display the token in text in the console, in the view html and in the
flash, and the token doesn't seem to be altered (though I had to
CGI.escape the token to get it right in Flash, and escape it again in
Flash to send it back, just because of the "+" that the token can
contains).

This is what the console shows for Firefox :

Token from controller = ayZ/bR7r2W3qg61NIspeOsU0N/VBqHqjWamkRtQG+s4=
←[4;36;1mSQL (0.0ms)←[0m ←[0;1mSET SQL_AUTO_IS_NULL=0←[0m

Processing UploadController#form (for 127.0.0.1 at 2010-08-01 13:12:25)
[GET]
Rendering upload/form
Completed in 11ms (View: 9, DB: 0) | 200 OK [http://localhost/]
←[4;35;1mSQL (0.0ms)←[0m ←[0mSET SQL_AUTO_IS_NULL=0←[0m


Processing UploadController#index (for 127.0.0.1 at 2010-08-01 13:12:29)
[POST]
Parameters: {"Filename"=>"Screenshot-14.jpg",
"authenticity_token"=>"ayZ/bR7r2
W3qg61NIspeOsU0N/VBqHqjWamkRtQG+s4=", "Upload"=>"Submit Query",
"Filedata"=>#<File:C:/Users/Lily/AppData/Local/Temp/RackMultipart.4856.0>}

ActionController::InvalidAuthenticityToken
(ActionController::InvalidAuthenticit
yToken):

And now for Internet Explorer :

Token from controller = i1irXTa0JqlbBNTlfcRwFYdQ24L8yhTBQFWESSrSEZg=
g=&=]
←[4;35;1mSQL (0.0ms)←[0m ←[0mSET SQL_AUTO_IS_NULL=0←[0m


Processing UploadController#form (for 127.0.0.1 at 2010-08-01 13:15:02)
[GET]
Rendering upload/form
Completed in 4ms (View: 2, DB: 0) | 200 OK [http://localhost/]
ost/]
←[4;36;1mSQL (0.0ms)←[0m ←[0;1mSET SQL_AUTO_IS_NULL=0←[0m


Processing UploadController#index (for 127.0.0.1 at 2010-08-01 13:15:19)
[POST]
Parameters: {"Filename"=>"MobilePhone_Icon.jpg",
"authenticity_token"=>"i1irXT
a0JqlbBNTlfcRwFYdQ24L8yhTBQFWESSrSEZg=", "Upload"=>"Submit Query",
"Filedata"=>#<File:C:/Users/Lily/AppData/Local/Temp/RackMultipart.4
856.2>}
Completed in 8ms (View: 1, DB: 0) | 200 OK
[http://localhost/upload?authenticity
_token=i1irXTa0JqlbBNTlfcRwFYdQ24L8yhTBQFWESSrSEZg=
]


Could someone help me about this ? I searched quite a while on the net
for an explaination; I found some people fix for Swfupload and
Uploadify/Paperclip but couldn't get a solution out of it.

(I'm using Rails 2.3.5 and Ruby 1.8.6 on this project, the Flash
application is in ActionScript 3 compiled for the player 10)
--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment