I have searched the archives and posted this message three times
and have yet to get a response. I am trying to create a web page
that let’s a user upload a file.
I have worked through most of the issues, and can even get
a file on to my server, but it is embedded in a binary file
whose format is unknown.
Has anyone experience with this, or is there documentation on
how to extract the file data from what is sent to the server?
Below is an example of the file I get from webrick.
The original contents of the file v.rb is “This is a test.\n”
file:
["\000\004v.rb\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\272
\267:\272G\233\205\000\000\000mBIN\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\202\201\256\022\000\000This
is a
test.\n\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"]
radio: [“2”]
text: [nil]
Thanks
···
–
Jim Freeze
“Benson, you are so free of the ravages of intelligence”
– Time Bandits
I have searched the archives and posted this message three times
and have yet to get a response. I am trying to create a web page
that let’s a user upload a file.
I have worked through most of the issues, and can even get
a file on to my server, but it is embedded in a binary file
whose format is unknown.
Has anyone experience with this, or is there documentation on
how to extract the file data from what is sent to the server?
I did this several years ago using Java. Got it working OK. IIRC it
should come back in a multipart MIME body. I think this is described in
rfc1867 [1].
However this does not appear to be the format that you are getting in
your file. You might need to dig around in the webrick code to see how
it is reading the actual HTML stream.
Also it might be worth trying to upload a .txt file as it might have
something to do with it not recognizing how to encode .rb file.
I did this several years ago using Java. Got it working OK. IIRC it
should come back in a multipart MIME body. I think this is described in
rfc1867 [1].
However this does not appear to be the format that you are getting in
your file. You might need to dig around in the webrick code to see how
it is reading the actual HTML stream.
Also it might be worth trying to upload a .txt file as it might have
something to do with it not recognizing how to encode .rb file.
Thanks for the tip. I tried a .txt file and it worked as it
should. Thanks. I also tried a .tgz file. This file had an
extra \0A on the end, but otherwise was ok.
I find it interesting that it did not treat the .rb file
as a text file.
Thanks for the link. I glanced it over and rfc1521 about mime
formats but did not have anything jump out at me as how to
set mime types for cgi. Can this be done?
Thanks again.
···
On Tuesday, 14 January 2003 at 21:54:16 +0900, Ross Shaw wrote:
–
Jim Freeze
Life is like an onion: you peel off layer after layer, then you find
there is nothing in it.
Thanks for the link. I glanced it over and rfc1521 about mime
formats but did not have anything jump out at me as how to set mime
types for cgi. Can this be done?
I read your original post and Ruby’s cgi.rb can understand file
uploads as described in rfc1867. The docs at the start of cgi.rb have
a heading ‘GET MULTIPART FORM VALUES’ that describes how.
Also it might be worth trying to upload a .txt file as it might have
something to do with it not recognizing how to encode .rb file.
Thanks for the tip. I tried a .txt file and it worked as it
should. Thanks. I also tried a .tgz file. This file had an
extra \0A on the end, but otherwise was ok.
I find it interesting that it did not treat the .rb file
as a text file.
Thanks for the link. I glanced it over and rfc1521 about mime
formats but did not have anything jump out at me as how to
set mime types for cgi. Can this be done?
I think the Content-Type may be determined by the browser. If this is
the case then the browser’s machine is the one responsible for knowing
that .rb files are text/plain.
I notice the webrick has a mime.types file that has rb defined as
text/plain so it should be able to handle knowing the content type of rb
files.