[Prev][Next][Index][Thread]

Support for uploading files in CL-HTTP.




I was wondering if anybody has been working with uploading files using
the html INPUT type FILE?  I noticed that there is some support already
present in CL-HTTP, insofar as the file type is defined as a legal value
for the accept-input macro.  I also get the data transferred when I
specify the encoding '(:multipart :form-data) for a form containing such
a file button.

My question is whether anyone else has worked on parsing the returned
data on the server end.  This involves breaking the message apart at
boundaries specified by the multipart encoding and then doing something
with the file data.

I have been doing a little bit of work on this, but would prefer not to
reinvent the wheel if code is already available.  A few of the issues
that I have already looked at (but not solved yet:)

Using READ-DELIMITED-LINE doesn't work to start reading input because
the stream remains open, so there is no EOF to detect.  There is a
special marker (the boundary marker followed by two hyphens) that does
mark the end of the entire transmission, so this can be used.

All sections are headed by a boundary marker,
                 followed by information about the content,
                 followed by a blank line
	         followed by data.

One interesting twist is that the end-of-line terminator for included
text files depends on the operating system on which the browser (client)
is running!  This can be different from the end-of-line terminator used
for rest of the multipart data stream.

I'm also trying to figure out what the best method of handling the form
data would be.  The parsing and transformation of other form data into
an AList representation is very convenient.  This could be done for some
of the data elements present in the form stream.  This leaves open the
question of how to deal with uploaded file data.  Perhaps the best
solution would be to allow a user-specified function be applied to a
stream containing the uploaded bytes.  This would allow the data to be
handled as it is read, buffered, or even saved to a file before further
processing.

Any thoughts or comments?

-Tom.

________________________________________________________________________
Thomas A. Russ,  Senior Research Scientist                   tar@isi.edu    
USC/Information Sciences Institute              WWW:  http://www.isi.edu
4676 Admiralty Way, Marina del Rey, CA 90292          (310) 822-1511x775


Follow-Ups: