[Seaside] saving & uploading files?
Julian Fitzell
seaside@lists.squeakfoundation.org
Wed, 28 Aug 2002 13:25:45 -0700
Tim Rowledge wrote:
> Julian Fitzell <julian@beta4.com> is claimed by the authorities to have written:
>
>
>>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.
>
> Err, putting
> <form sea:id="upload">
> <iafileupload sea:id+"uploadedFile"></iafileupopload>
> </form>
> in my page gets me an error complaining about there not being a page
> class set? Whaddididowrong?
> I was going to try the www.w3.org pages to see if they explain anything,
> but good old ATT won't let me resolve more than a few urls at the moment
> and I can't get there...
Sorry, I wasn't thinking right myself so I definitely didn't explain it
right. What you want to do is just insert <input type="file"
sea:id="uploadFile">. IAFileUpload is a tag not a component, sorry.
>>You could do something like:
>>
>>mimeDocument
>> ^ MIMEObject contentType: 'text/plain' content: 'This is a test'
>
> Whoops, MIMEDocument!
:)
>>
>>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.
>
> That works ok, although as you say it is plain text and just gets
> displayed. Can't think of any plausible alternative formatto use right
> now. MP3 is not exactly appropriate :-)
Hmm, yeah you could use "application/octet-stream" or something to make
sure it gets downloaded. Depending on the format of the data, you could
use, for example "application/csv" for comma-separated data files.
Technically you can send a "Content-disposition:" header that asks the
browser to save instead of displaying the file, though I don't know if
all browsers support it. As far as I know Seaside doesn't support it
directly though. If you want to be pure about it you could change your
IADynamicResource subclass to add the header in #printContentsTo: before
calling super. This might even be a nice addition to the base class...
just have a boolean instvar that indicates whether to force the browser
to download the file. If you felt like adding and testing that, I'd
happily apply the changeset.
Julian
--
julian@beta4.com
Beta4 Productions (http://www.beta4.com)