[REBOL] Re: need advice on parsing image data
From: brett:codeconscious at: 28-Apr-2001 15:02
I got the post-data file from the url of your earlier message.
I'm no expert but here's my thinking.
1) The data returned from the post should initially be treated as binary -
because you have image data that is binary and has not been encoded. So what
I did was use read/binary to get your post-data file. I don't know for sure,
but it is possible some clients may upload the file data in a different
encoding like Base 64 rather than straight binary. So you may need to handle
the case where a content-transfer-encoding header is given.
2) Though you data is binary doesn't mean you can't parse it like a string.
Just remember to use /all refinement of parse.
I already had some mime type handling stuff for emails. So I changed around
a little bit to handle your file as well. It is very possible I still
haven't handled the RFCs properly but it seems to work at the moment.
Using Rebo/View Try this script - The view part is just to show that I
succesfully got your image data.
post-data: read/binary http://www.fargonews.com/post-data
r: decode-mime-parts mime-parts? post-data
write/binary %tf.jpg r/7/content
view layout [image %tf.jpg]
BTW I'd like to know how to display the image without having to write the
file first - anyone - please?
Hope it helps you.
----- Original Message -----
Sent: Saturday, April 28, 2001 6:28 AM
Subject: [REBOL] need advice on parsing image data
When I post a form entry and a file using multipart/form-data encoding, I
get the following....
Content-Disposition: form-data; name="content"
Content-Disposition: form-data; name="file"; filename="D:
ÿØÿà (plus a whole bunch more characters that I am unable to
This is an easy parse. However, REBOL will not parse the image data. It
gets stuck when it reaches an unknown character, which shows up in Notepad
as a square. As you can see, I'm not even able to copy-and-paste the actual
image data from the text file into this e-mail. Does anyone have any advice
on how to parse this image data?
Ryan C. Christiansen
4733 Amber Valley Parkway
Fargo, ND 58104
701-235-3390 ext. 6671
Global Leader in People Performance Software
This message may contain privileged and confidential information. If you
think, for any reason, that this message may have been addressed to you in
error, you must not disseminate, copy or take any action in reliance on it,
and we would ask you to notify us immediately by return email to