Dynamic Parsing of a stream of binary data

  • Thread starter Thread starter Michael Kolias
  • Start date Start date
M

Michael Kolias

Hello everyone and happy holidays!

I have a situation where I want to parse on the fly a stream of binary data.
I am developing an httpmodule for asp.net for file uploading.

I do not whant to use the built-in control because it's inadequate.

In theory I would use a que and feed data as it comes in and then have
a parser that extracts the data from the que, parse them and do whatever.

The problem here is that I am dealing with raw binary data that sometimes
could
be hunderds of megabytes.

Should I use the built-in que class and store the data byte by byte?
How would someone go on creating a first-in first-out buffer of bytes with
managed code?


Michael.
 
One idea might be to wrap the stream in a BufferedStream. That way you
would not need to cache the data in a queue as you could read it directly
from the BS. That way you are not bound by just bytes or fixed length
strings. You could provide the BS to the consuming code and read as many
bytes as necessary for that particular operation.
 
Your problem is a lot deeper than you think, as the binary stream contains a
whole bunch of data that forms part of RFC 1867 for uploading multipart form
data from a web browser. So you have to parse the stream before you can
even begin to pick out the part you need containing the file for any other
submitted form data, and if your boundaries are wrong your file will be
corrupted along with ther rest of your http submission.

Take a look at what others have done as a starting point to get an idea of
what it involves.
http://www.asp.net/ControlGallery/ControlDetail.aspx?Control=2791&tabindex=0

Me- I would buy one of the existing ones, for what they cost its not worth
the work these days.
 
Back
Top