Hi folks Searching the list, I notice this problem was introduced a while back but there was no reply. Anyhow, I''m now finding myself up against it: I''m trying to upload zip files and unzip them into a directory using rails. It works fine with larger files; here''s the data at the breakpoint: irb(#<UploadController:0x2262a84>):001:0> params => {"commit"=>"Upload", "action"=>"save_file", "controller"=>"upload", "site"=>{"name"=>"dh", "zip_file"=>#<File:/tmp/CGI805.1>}} However, with a smaller file (not just with zip files, actually) i get the following: irb(#<UploadController:0x24ad6a4>):001:0> params => {"commit"=>"Upload", "action"=>"save_file", "controller"=>"upload", "site"=>{"name"=>"smalltest01", "zip_file"=>#<StringIO:0x24e0ce8>}} and the path returns nil. Does anybody have any insight into this problem? Any help would be appreciated. Thanks cheers dafydd --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi~ On Jan 1, 2007, at 12:03 PM, dafydd wrote:> > Hi folks > > Searching the list, I notice this problem was introduced a while back > but there was no reply. Anyhow, I''m now finding myself up against it: > > I''m trying to upload zip files and unzip them into a directory using > rails. It works fine with larger files; here''s the data at the > breakpoint: > > irb(#<UploadController:0x2262a84>):001:0> params > => {"commit"=>"Upload", "action"=>"save_file", "controller"=>"upload", > "site"=>{"name"=>"dh", "zip_file"=>#<File:/tmp/CGI805.1>}} > > However, with a smaller file (not just with zip files, actually) i get > the following: > > irb(#<UploadController:0x24ad6a4>):001:0> params > => {"commit"=>"Upload", "action"=>"save_file", "controller"=>"upload", > "site"=>{"name"=>"smalltest01", "zip_file"=>#<StringIO:0x24e0ce8>}} > > and the path returns nil. > > Does anybody have any insight into this problem? Any help would be > appreciated. > > Thanks > > cheers > dafyddThats the way rails works. If an uploaded file is less then 10Kb then it will be put in a StringIO, if it is over 10k it will get put in a tmpfile. You will have to branch with conditionals on this to support what you want. If its a StringIO then you need to read it into mem and write it out to wherever you want it. If its a tmpfile then you can just call path on it and move it somewhere. if StringIO === params[:zip_file] data = params[:zip_file].read File.open(''some/path'', ''wb''){|f| f.write data } else # its a tmpfile end Cheers- -- Ezra Zygmuntowicz -- Lead Rails Evangelist -- ez-NLltGlunAUd/unjJdyJNww@public.gmane.org -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273) --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Yow! Thanks, Ezra. You Rails folks are exceptionally patient and helpful with newbies. cheers dafydd --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
dafydd wrote:> You Rails folks are exceptionally patient and helpful with newbies.Because Rails is too. ;-) -- Phlip http://www.greencheese.us/ZeekLand <-- NOT a blog!!! --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
dafydd wrote:> You Rails folks are exceptionally patient and helpful with newbies.As long as you aren''t trying to type } in irb on a non-English keyboard! Then we bite you with large teeth. :/ rluv -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---