Wes Gamble
2006-Apr-03 17:01 UTC
[Rails] Multiple file uploads - only one file object gets posted
All, Trying to upload multiple files. Form: <% index = 0 for @image in images do %> <TR> <TD> <%= @image.path.split(''/'').last[0..39] %>: <% if ((! @image.path.nil?) && (@image.path.length > 40)) %> <%= h("...") %> <% end %> </TD> <TD> <%= file_field(''image'', ''fileobj'', :index => index) %> </TD> </TR> <% index += 1 end %> I browse for 3 of the many files, and submit the form: When I look at params in the controller, I see: "0"=>{"fileobj"=>#<File:C:/DOCUME~1/WESLEY~1/LOCALS~1/Temp/CGI2444.0>} but the other two indices for which I expected File objects only show StringIO objects. Why do I not see 3 files objects in my parameter array when I "Browse..." to three files and submit my form? Thanks, Wes -- Posted via http://www.ruby-forum.com/.
Markus Piff
2006-Apr-10 21:56 UTC
[Rails] Multiple file uploads - only one file object gets posted
Hi, this isn''t a real problem, which you are experiencing here. Due to this CGI stuff, a large "File" gets mapped in a File object, whereas small files are being represented by StringIO objects. The reason, why it is done in this way may be performance, but I''m not really sure about this. To make the long story short, everything seems to be in order. Markus On 4/3/06, Wes Gamble <weyus@att.net> wrote:> > All, > > Trying to upload multiple files. > > Form: > > <% index = 0 > for @image in images do %> > <TR> > <TD> > <%= @image.path.split(''/'').last[0..39] %>: > <% if ((! @image.path.nil?) && (@image.path.length > 40)) %> > <%= h("...") %> > <% end %> > </TD> > <TD> > <%= file_field(''image'', ''fileobj'', :index => index) %> > </TD> > </TR> > > <% index += 1 > end > %> > > I browse for 3 of the many files, and submit the form: > > When I look at params in the controller, I see: > > "0"=>{"fileobj"=>#<File:C:/DOCUME~1/WESLEY~1/LOCALS~1/Temp/CGI2444.0>} > > but the other two indices for which I expected File objects only show > StringIO objects. > > Why do I not see 3 files objects in my parameter array when I > "Browse..." to three files and submit my form? > > Thanks, > Wes > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060410/d0a136a1/attachment.html
Wes Gamble
2006-Apr-11 16:07 UTC
[Rails] Re: Multiple file uploads - only one file object gets posted
I don''t have access to the original file name from a StringIO object though, correct? So I will either have to capture the file name another way or just rename it myself? Wes Markus Piff wrote:> Hi, > > this isn''t a real problem, which you are experiencing here. > Due to this CGI stuff, a large "File" gets mapped in a File object, > whereas > small files are being represented by StringIO objects. The reason, why > it is > done in this way may be performance, but I''m not really sure about this. > > To make the long story short, everything seems to be in order. > > Markus-- Posted via http://www.ruby-forum.com/.
Markus Piff
2006-Apr-16 20:26 UTC
[Rails] Re: Multiple file uploads - only one file object gets posted
Hi, you do have access to the original filename, but the methods are different. For StringIO the method should be "original_filename" whereas for File instances <http://www.nabble.com/forum/ViewPost.jtp?post=3729395&framed=y> the method is "path". So you see, you don''t have to rename anything. Sorry for the late answer, I was quite busy this week. Markus On 4/11/06, Wes Gamble <weyus@att.net > wrote:> > I don''t have access to the original file name from a StringIO object > though, correct? > > So I will either have to capture the file name another way or just > rename it myself? > > Wes > > Markus Piff wrote: > > Hi, > > > > this isn''t a real problem, which you are experiencing here. > > Due to this CGI stuff, a large "File" gets mapped in a File object, > > whereas > > small files are being represented by StringIO objects. The reason, why > > it is > > done in this way may be performance, but I''m not really sure about this. > > > > > To make the long story short, everything seems to be in order. > > > > Markus > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060416/b182307c/attachment.html
Wes Gamble
2006-Apr-16 22:22 UTC
[Rails] Re: Re: Multiple file uploads - only one file object gets po
Markus, I was unable to find an original_filename method on the StringIO object. Are you sure it''s there? Wes Markus Piff wrote:> Hi, > > you do have access to the original filename, but the methods are > different. > For StringIO the method should be "original_filename" whereas for File > instances > <http://www.nabble.com/forum/ViewPost.jtp?post=3729395&framed=y> > the method is "path". > > So you see, you don''t have to rename anything. > Sorry for the late answer, I was quite busy this week. > > Markus-- Posted via http://www.ruby-forum.com/.