Re: Parsing Multipart formdata
- From: "ssamuel" <ssamuel@xxxxxxxxx>
- Date: 16 Nov 2006 09:37:22 -0800
Cuong.Tong@xxxxxxxxx wrote:
I can get my code to do up to step 5 of your algorithm, which is to
readin in the headers eg: filename and contentType. After this, there
will be a \r and \n which consititue of 2 bytes.
In general, be a little wary about line breaks. If you're designing a
system that will read only from one source, you're fine. If you're
reading from more than one source, you may not always get \r\n, and, if
you do, they may not be in that order.
That's a small concern, though.
So I can just have a string object then have buffer.readline ? And for
each of the line i compare it if it contains the boundary?
Yes, but you probably want to use a StringBuilder.
Is my data integrity will be broken, eg file corruption if i read the
stream in as string, then base64decode it, then convert it to bytes
array.
That'll work fine. Just make sure you're feeding only the
Base64-encoded data to the decoder or it'll choke.
If reading the stream in doesnt break the data integrity, I think it
should be good because I can just read the wholething in with
stream.ReadToEnd(); then use regular expression or string.split to
split the multiparts to different part.
You can do that.
In fact, you can ReadToEnd() from the beginning if you want and regex
or split into pieces. Since System.Convert doesn't have stream
processing methods anyway, you're going to end up putting everything
into a big string anyway.
You may be able to specify a single regex that'll take the whole
message and split out just the Base64 stuff, or find such a regex on
the Internet somewhere. If I wasn't behind on my project deadline, I'd
write you one myself as it seems like an interesting problem.
Stephan
.
- References:
- Parsing Multipart formdata
- From: Cuong.Tong@xxxxxxxxx
- Re: Parsing Multipart formdata
- From: ssamuel
- Re: Parsing Multipart formdata
- From: Cuong.Tong@xxxxxxxxx
- Parsing Multipart formdata
- Prev by Date: BackGroundWorker.ReportProgress method doesn't accept strings
- Next by Date: Re: BackGroundWorker.ReportProgress method doesn't accept strings
- Previous by thread: Re: Parsing Multipart formdata
- Next by thread: Can't read network path?
- Index(es):