[Seaside] saving & uploading files?

Julian Fitzell seaside@lists.squeakfoundation.org
Wed, 28 Aug 2002 12:15:57 -0700

Tim Rowledge wrote:
> Julian Fitzell <julian@beta4.com> is claimed by the authorities to have written:
>>Not sure I ever tried using it myself but I think that was how it was 
>>supposed to work.  Have you had specific problems with it or just 
>>wondering where to start?
> The latter; I've no idea what one does to provide for an upload
> field/form/entry/whatever it is.

Well, like I said, you *should* be able to just put an IAFileUpload in 
your form, bound to a variable and that variable will contain the IAFile 
object when the form is submitted.

> And let's not forget the download stuff; the only approach I can think
> of at the moment is to save the info to a file and just return it from
> a new URL. That simply has to be wrong - its so ugly.

Downloads can be accomplished by subclassing IADynamicResource.  See 
IAFormResource for an example that returns an image.  You just need to 
subclass IADynamicResource and define a #mimeDocument method.

You could do something like:

  ^ MIMEObject contentType: 'text/plain' content: 'This is a test'

So now if you do:

self callPage: IAMyDynamicResourceSubclass new

the user would be prompted to download a text file.  Actually, in this 
case the browser would probably just display it since it is 'text/plain' 
hopefully that gets the idea across.

Make sense?

Beta4 Productions (http://www.beta4.com)