Hi list
I have to admit that I feel this is a stupid question, but two days of
Web search(1) and trials with WEBRick and CGI did not bring me any
closer.
Here is the problem:
I am uploading files to my Webrick server via the standard HTTP method:
the Webrick do_POST handler than has the multipart/form-data in his
req.body.
As astonishing as that sounds, I have not found a way to get the
file’s content out of this.
I am sure there should be an easy way.
BTW I have browsed the ML archives and there are some references to
CGI but I just could not glue it together 
All help is appreciated.
Robert
(1) a badly known synonym for “googling” 
I am sure there should be an easy way.
Here’s something I found from Google. It may not be definitive, sorry,
but I think it can help!
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/94785
Arle.
On 8/9/07, Arlen Christian Mart C. [email protected] wrote:
file’s content out of this.
I am sure there should be an easy way.
Here’s something I found from Google. It may not be definitive, sorry,
but I think it can help!
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/94785
That was indeed one of my first hits and it was useful to get the form
right, please note however that he is not doing anything with the
uploaded data :(, just sending it back.
And this exactly where it hurts, I cannot glue the received data
(req.body) into CGI, which would seem to do the multipart/form-data
conversion just fine.
Actually I would not care to save the body as such into a file and
have an external converter do the job(1), if I only had such an
external converer :(.
Thx anyway
Robert
(1) even if not in Ruby, sorry for the OL in that case.
2007/8/9, Robert D. [email protected]:
I have to admit that I feel this is a stupid question, but two days of
Web search(1) and trials with WEBRick and CGI did not bring me any
closer. (…)
Bonsoir Robert.
Google didn’t help me either, but I’m using a Ruby wiki called “Soks”,
which runs on WEBrick and offers file uploads. Reading the code it
seems that the following should work:
upload_data = request.query[“data”]
File.open(upload_data.filename, “wb”) do |file|
upload_data.each_data do |data|
file << data.to_s
end
end
Take a look at WEBrick::HTTPUtils::FormData.
I haven’t tested it, but I HTH.
Regards,
Pit
On 8/10/07, Pit C. [email protected] wrote:
Regards,
Pit
I knew it would be simple, but that simple!!!
Works like charm.
Merci beaucoup Pit, meine Dankbarkeit wird Dir für immer nachschleifen
(sorry folks for these old Viennese saying 
Robert
I thought I share the outcome of this, a very primitive file server we
need for some file transfer for folks caught behind a firewall and a
mean Proxy. Only https passes.
This might be useful for some low to medium traffic transfers.
I will use it on demand only, it is not really tested and there might
(there are for sure) some security issues. I have checked the most
obvious.
Runs on any system you can execute df -k
in your Ruby code (that
part can be commented out if one needs to do so).
Hope this might be helpful in case somebody searches the archives for
multipart/form-data File upload WEBrick File Server
Cheers
Robert