[Rails] File.size() on Uploaded Images Fail

Jeff Ward
Mon, 29 May 2006 22:03:36 -0000

Of course! This works.

Or course this works.

:)

Thanks,

Jeff


On 5/29/06, Phillip Hutchings <sitharus@sitharus.com>
wrote:
>
> >    def newfile=(newfile_field)
> >     self.filename > >
base_part_of(newfile_field.original_filename)
> >     self.filetype = newfile_field.content_type.chomp
> >     self.filesize = File.size(newfile_field) ### It fails on this line
> for
> > images...
> >   end
> >
> > The error I get is: "can''t convert StringIO into
String"
>
>
> File.size tells you the size of the file you give it by name, eg
> File.size(''/etc/passwd/''). You have a StringIO object,
which is just
> another type of IO object. You want to use newfile_field.size.
>
> --
> Phillip Hutchings
> http://www.sitharus.com/
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
-------------- next part --------------
An HTML attachment was scrubbed...