Ha! I wondered if I would manage to incur the wrath of Zed...
He is, as always, correct... That's what I get for having outdated Rails
wiki code stuck in my head.
require 'fileutils'
@file = params[:model][:file_field]
FileUtils.mv @file.local_path, "/path/to/[EMAIL PROTECTED]"
I assume this is what I should do instead, correct?
And yeah, I'll second Zed's comment on S3... That's what I'm doing, in
conjunction with Backgroundrb, because of some post-processing. Works great.
Matt
On 11/29/06, Zed A. Shaw <[EMAIL PROTECTED]> wrote:
On Tue, 28 Nov 2006 14:20:06 -0600
[EMAIL PROTECTED] wrote:
>
> On Nov 28, 2006, at 1:50 PM, Matt White wrote:
>
> > Rogelio,
> >
> > It will arrive in Rails just like any other uploaded file... It
> > will show up in params[:model][:file_field], or whatever you've
> > named your input file field. Until you do something else with it,
> > it only lives as a file in /tmp/. You need to move it somewhere
> > else, though, because Rails will do away with it once the request
> > is complete :)
> >
> > Something like:
> >
> > @file = params[:model][:file_field]
> > File.open("/path/to/[EMAIL PROTECTED]", "wb") { |file|
> > file.write(@file.read) }
Matt, don't do this. In fact, if there's code in Mongrel doing this then
point it out to me.
You already have the fully formed file handle, all you need to do is use
fileutils to just rename it. This is an ultra fast operation. Don't copy
it in a loop inside ruby.
> This is what I'd like to improve in Mongrel. It's really wasteful to
> write the file to a TempFile and then rewrite it again elsewhere. For
> really big files (multi-gigabyte) the performance hit would be
> tremendous.
Matt's mistaken Cremes, this isn't how it's done.
> I'm thinking furiously about how to properly manage this. If anyone
> has any ideas, feel free to share them on the list.
You probably have been missing the entire chunk of code I and Ezra have
been working on to solve this problem. Including a modified string search
algorithm that will find the mime boundaries. If you wanna help on this,
e-mail me off line with your ideas and I'll help you check out the source.
I haven't been ignoring your other ideas, they're just kind of secondary
to the Mongrel 1.0 RC1 release. I'm pushing for this stuff in more of a
Mongrel 1.1 or later release.
--
Zed A. Shaw, MUDCRAP-CE Master Black Belt Sifu
http://www.zedshaw.com/
http://www.awprofessional.com/title/0321483502 -- The Mongrel Book
http://mongrel.rubyforge.org/
http://www.lingr.com/room/3yXhqKbfPy8 -- Come get help.
_______________________________________________
Mongrel-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/mongrel-users
--
Matt White
-----------------------
Thermal Creative
http://blog.thermalcreative.com
_______________________________________________
Mongrel-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/mongrel-users