[Seaside] How to save file downloads (or is it uploads?)

Nevin Pratt seaside@lists.squeakfoundation.org
Sat, 11 Jan 2003 17:53:02 -0700


This isn't a Seaside question, but all the guys on this list seem pretty 
sauvy about this topic.  I hope you'll not mind me posting here...

Anyway, I'm using Comanche to drive a web site (actually, four different 
web sites).  One of my pages has the familiar INPUT tag as follows:

  <input type="file name="FileUpload" value="">

When the user hits the submit button for the page, I do indeed see what 
looks to be a proper HttpRequest instance come through Commanche.

This HttpRequest instance has a a 'stream' ivar that is an instance of 
SocketStream.
The SocketStream instance has an 'inStream' ivar that is an instance of 
BufferStream.
The BufferStream instance has a 'buffer' ivar that is a String.
That String does indeed contain the contents of the file that the 
browser tried to upload, but it is embedded within a bunch of other stuff.

I'm sure there's an API somewhere that lets me just grab the incoming 
file and save it somewhere, but I can't seem to find it.  Lacking an 
API, I would have to explicitly parse the string contents mentioned 
above.  I'm pretty sure I really don't need to do that, and there is 
some other (easier) way.

But, how the heck do you do it?

Again, I just want Comanche to grab an incoming file stream and save the 
file to an 'incoming' directory.  And the incoming file stream came 
about by using the standard html INPUT tag mentioned above.

Anybody know how to do this?  It seems like it should be a trivial task, 
but it's got me stumped :-)

Nevin