SWFupload

Hi All,

Does anyone managed to run SWFUpload with rails 2.0.2 ?

Any help greatly appreciated !

Regards,
Lukas

Create a session_patch.rb file in the initializers directory, with the
following content. Use the cookie_only session setting toallow the
desired
actions to receive the session id outside the cookie:

ex: session :cookie_only => false, :only => %w(file_upload)

– cut here –

class CGI::Session
alias original_initialize initialize

The following code is a work-around for the Flash 8 bug that

prevents
our multiple file uploader

from sending the _session_id. Here, we hack the Session#initialize

method and force the session_id

to load from the query string via the request uri. (Tested on

Lighttpd,
Mongrel, Apache)
def initialize(cgiwrapper, option = {})
#RAILS_DEFAULT_LOGGER.debug “#{FILE}:#{LINE} Session options
#{
option.inspect} *********************”
unless option[‘cookie_only’]
#RAILS_DEFAULT_LOGGER.debug “#{FILE}:#{LINE} Initializing
session object #{cgiwrapper.env_table[‘RAW_POST_DATA’]}
*********************”
session_key = option[‘session_key’] || ‘_session_id’

  query_string = if (rpd = cgiwrapper.env_table['RAW_POST_DATA']) 

and
rpd != ‘’
rpd
elsif (qs = cgiwrapper.env_table[‘QUERY_STRING’]) and qs != ‘’
qs
elsif (ru =
cgiwrapper.env_table[‘REQUEST_URI’][0…-1]).include?(’?’)
ru[(ru.index(’?’) + 1)…-1]
end
if query_string and query_string.include?(session_key)
option[‘session_id’] =
query_string.scan(/#{session_key}=(.?)(&.?)*$/).flatten.first
end
end

original_initialize(cgiwrapper,option)

end

end

On Jan 23, 2008 4:13 PM, luk asz [email protected]
wrote:

Posted via http://www.ruby-forum.com/.


Eider Oliveira

Site: http://eider.eti.br
Blog: http://eider.eti.br/Home/Blog/Blog.html

“If I had more time, I’d have written you a shorter letter.” Pascal

On 24 Jan 2008, at 10:57, Eider Oliveira wrote:

Create a session_patch.rb file in the initializers directory, with
the following content. Use the cookie_only session setting to
allow the desired actions to receive the session id outside the
cookie:

ex: session :cookie_only => false, :only => %w(file_upload)

This probably only works if you’re using a database session table and
not the new cookie based session i presume?

Best regards

Peter De Berdt

Thank you for the hint.

I will try that and post later if that worked out for me.

Regards,
Lukasz

Hello Eider,

Unfortunately this fix does not work for me. I am using
restful_authentication and I receive this error in logfile:

ActionController::InvalidAuthenticityToken

I tried to URL.encode the session id but it does not work. I have been
playing with this issue for so much time that I am totally lost.

Maybe there is any other hint from your side more…

Regards,
Lukasz

I expect it to work on all session stores (including memcache),
excepting
the new cookie store. If you can’t send the session Id in a cookie, you
won’t be able to send the session cookie.

On Jan 24, 2008 9:02 AM, Peter De Berdt [email protected]
wrote:

This probably only works if you’re using a database session table and not


Eider Oliveira

Site: http://eider.eti.br
Blog: http://eider.eti.br/Home/Blog/Blog.html

“If I had more time, I’d have written you a shorter letter.” Pascal

I’m using it, but it’s not tied to rails. What’s your problem? Picking
it up in the controller?

works for me.

What OS?

eggie5 wrote:

I’m using it, but it’s not tied to rails. What’s your problem? Picking
it up in the controller?

This is nuts !

It works under IE7 but does not work under Firefox 2 ! ?

It’s sick :slight_smile:

Regards,
Lukasz

eggie5 wrote:

works for me.

What OS?

I use Ubuntu. But here next to my computer stands windows machine.

Simply:
Windows FF - does not work
Windows IE7 - works
Linux Firefox - does not work

I have almost given up.

Any ideas ? Maybe it’s a problem with that fix provided at the beginning
of the topic ?

Lukasz

eggie5 wrote:

works for me.

What OS?

ok so could you post all of your rails app settings and code snips
please… i am really getting out of ideas… :slight_smile:

thanks
lukasz

What isn’t working with it?

eggie5 wrote:

What isn’t working with it?

Indeed it is working but just in Internet Explorer 7. I found an
information that flash player for Firefox is problematic. Do you have
any fix for that ?

Regards,
Luaksz

Would someone mind posting a complete tutorial for integrating
SWFUpload into a rails app? I’ve seen several blog entries
referencing how amazing and how cool it is, but not a single entry
takes you from start to finish. Even the screencasts I’ve seen are
vague at best.

I’ve tried integrating it (without auth requirements even) but it
simply fails. I’m sure it’s a combination of my missing something
combined with the fact that the RAILS/SWFUPLOAD combo isn’t fully
documented in a straight-forward manner. Obvious, no? :wink:

Anyway, any assistance would be much appreciated.

Regards.

i implemented something with swfupload and simply announce the files
with an ajax call before uploading them, storing some record in the db,
handing back some id/code which then is posted together with the file
upload. that way i get normal session handling and nobody can upload
anything without that ‘handshake’. i think that’s secure enough.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs