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

Nevin Pratt nevin at
Sun Jan 12 01:45:29 UTC 2003

Ahh, the trick is shown in WAKom>>processMultipartFields:

Once that method is run, you end up with a WAFile instance as one of 
your post fields in the HttpRequest.  And you can do what you want with 
the WAFile instance (save it to disk, whatever).

Sorry to bother everyone.


Nevin Pratt wrote:

> 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

More information about the Squeak-dev mailing list