hey guys, the way i''m handling file uploads is no good, but i''m not sure what the best way to go about it is. right now my approach is to use FileUtils.mv to move the uploaded file to the directory i want it in. this approach doesn''t work well because sometimes the uploaded file is just an IO object instead of a temporary file (apparently small files aren''t put into temp files according to the CGI documentation). anyway, how should i be doing this? i like just using ''mv'' to move the files... is there a way i can force cgi to store everythng as a temporary file? i also tried using the IO#read method to read the uploaded files data into a new file, but that didn''t seem to get the MIME-type and stuff in there... what should i do? thanks, cam --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Thu Aug 24, 2006 at 03:18:47PM -0600, Cam wrote:> > hey guys, > > the way i''m handling file uploads is no good, but i''m not sure what > the best way to go about it is. right now my approach is to use > FileUtils.mv to move the uploaded file to the directory i want it in. > this approach doesn''t work well because sometimes the uploaded file is > just an IO object instead of a temporary file (apparently small files > aren''t put into temp files according to the CGI documentation). > anyway, how should i be doing this? i like just using ''mv'' to move > the files... is there a way i can force cgi to store everythng as a > temporary file?yes, if you modify the cgi module if you dont want to handle the workaround yourself, theres acts_as_attachment and file_column plugins.. i also tried using the IO#read method to read the> uploaded files data into a new file, but that didn''t seem to get the > MIME-type and stuff in there... what should i do? > > thanks, > cam > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Cam wrote:> hey guys, > > the way i''m handling file uploads is no good, but i''m not sure what > the best way to go about it is. right now my approach is to use > FileUtils.mv to move the uploaded file to the directory i want it in. > this approach doesn''t work well because sometimes the uploaded file is > just an IO object instead of a temporary file (apparently small files > aren''t put into temp files according to the CGI documentation). > anyway, how should i be doing this? i like just using ''mv'' to move > the files... is there a way i can force cgi to store everythng as a > temporary file? i also tried using the IO#read method to read the > uploaded files data into a new file, but that didn''t seem to get the > MIME-type and stuff in there... what should i do? > > thanks, > camCam - I''d go with file_column plugin like Carmen said. Though I found it''s documentation a little lacking, I''ve seen a few topics on this mailing list that should help you figure out how to use it. Once you figure it out (it''s very simple, but not completely obvious without seeing a good example) it should be exactly what you are looking for. -Ben Lisbakken --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 8/24/06, Ben Lisbakken <lisbakke-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Cam - I''d go with file_column plugin like Carmen said. Though I found > it''s documentation a little lacking, I''ve seen a few topics on this > mailing list that should help you figure out how to use it. Once you > figure it out (it''s very simple, but not completely obvious without > seeing a good example) it should be exactly what you are looking for.file_column looks really cool. it actually does way more than i need it to, and i don''t like the places it''s putting the files on the drive, but i should be able to modify that pretty easily. i don''t really understand where in his code he''s handling the stringio case, but i''ll have to look over it more thoroughly. thanks! cam --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---