[REBOL] Re: need advice on parsing image data
From: brett:codeconscious at: 28-Apr-2001 15:02
Hi Ryan,
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.
do http://www.codeconscious.com/rebol-library/message-tools.r
post-data: read/binary http://www.fargonews.com/post-data
r: decode-mime-parts mime-parts? post-data
---------------------------7d1a92c9014c
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.
Brett Handley
----- Original Message -----
From: <[ryan--christiansen--intellisol--com]>
To: <[rebol-list--rebol--com]>
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....
-----------------------------7d1a92c9014c
Content-Disposition: form-data; name="content"
content
-----------------------------7d1a92c9014c
Content-Disposition: form-data; name="file"; filename="D:
\fgonews\ad_graphic_01.jpg"
Content-Type: image/pjpeg
ÿØÿà (plus a whole bunch more characters that I am unable to
copy-and-paste)
-----------------------------7d1a92c9014c--
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
Web Developer
Intellisol International
4733 Amber Valley Parkway
Fargo, ND 58104
701-235-3390 ext. 6671
FAX: 701-235-9940
http://www.intellisol.com
Global Leader in People Performance Software
_____________________________________
Confidentiality Notice
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
[ryan--christiansen--intellisol--com]