How to save file downloads (or is it uploads?)
nevin at smalltalkpro.com
Sun Jan 12 00:50:49 UTC 2003
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
The SocketStream instance has an 'inStream' ivar that is an instance of
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 :-)
More information about the Squeak-dev