Forum: Mongrel File Upload without the Temp File Copy

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
62711fa2787e85b5f0c88e245ef69f54?d=identicon&s=25 Alexey Petrushin (axyd80)
on 2008-11-18 03:30
Is it possible to upload file directly into database?
Without creation the extra temp file on the disk.

Thanks! :)
Dcca95e5f8c0b97b930086b434027a90?d=identicon&s=25 Michael D'Auria (Guest)
on 2008-11-18 17:06
(Received via mailing list)
Is there a reason why you are avoiding the filesystem for storage?

Michael
62711fa2787e85b5f0c88e245ef69f54?d=identicon&s=25 Alexey Petrushin (axyd80)
on 2008-11-18 17:37
Michael D'Auria wrote:
> Is there a reason why you are avoiding the filesystem for storage?
>
> Michael

Yes, i'm using abstract storage interface, that can be implemented as
local file system, remote file system, distributed file system,
database, cache.

In this case the temp file is not needed. I can just switch the input
stream to it's destination without lost performance on not needed IO
operations.
72ea925c0ca3d19fdd2f12fa76681624?d=identicon&s=25 Stephan Wehner (stephanwehner)
on 2008-11-18 18:19
(Received via mailing list)
On Tue, Nov 18, 2008 at 8:37 AM, Alexey Petrushin <lists@ruby-forum.com>
wrote:
> stream to it's destination without lost performance on not needed IO
> operations.

You could look at the Ruby code that produces the temporary files, and
change it.
It is in method CGI::QueryExtension#read_multipart in cgi.rb
(/usr/lib/ruby/1.8/cgi.rb on my machine)

Stephan

> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Mongrel-users mailing list
> Mongrel-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/mongrel-users
>



--
Stephan Wehner

-> http://stephan.sugarmotor.org
-> http://www.thrackle.org
-> http://www.buckmaster.ca
-> http://www.trafficlife.com
-> http://stephansmap.org -- blog.stephansmap.org
-> http://loggingit.com -- blog.loggingit.com
6076c22b65b36f5d75c30bdcfb2fda85?d=identicon&s=25 Ezra Zygmuntowicz (Guest)
on 2008-11-18 18:46
(Received via mailing list)
On Nov 18, 2008, at 9:19 AM, Stephan Wehner wrote:

>>
>> In this case the temp file is not needed. I can just switch the input
>> stream to it's destination without lost performance on not needed IO
>> operations.
>
> You could look at the Ruby code that produces the temporary files, and
> change it.
> It is in method CGI::QueryExtension#read_multipart in cgi.rb
> (/usr/lib/ruby/1.8/cgi.rb on my machine)



  Mongrel doesn't actually use CGI.rb, thats only rails. You want to
look in http_request.rb and patch the code that writes to a tmpfile
and have it write to wherever  you want:

http://mongrel.rubyforge.org/browser/trunk/lib/mon...

Cheers-

Ezra Zygmuntowicz
ez@engineyard.com
This topic is locked and can not be replied to.