[Seaside] (no subject)

Keith Hodges keith_hodges at yahoo.co.uk
Sun Jul 22 00:30:37 UTC 2007


Maarten MOSTERT wrote:
> Hi,
> I am trying to add a download button to my application to serve a 20MB application file.
> I don't manage figure out how to make button that triggers a download dialog ?
> I also wonder if MyFileLibrary is the right way to do so ?
> Thanks in adavance,
> @+Maarten,
>
>   
Hello Maarten,

some code from Gjallar for doing this

 Rendering the anchor:

                    html
                            anchor
                            callback: [attachment downloadInSession: 
self session]
                            tooltip: 'Download file';
                            with: [ html html: attachment localFileName].
                        

Attachment-downloadInSession: session

    | stream |
    stream := self readStream.
    session download: stream mimeType: stream mimeType filename: 
localFileName


WASession-download: contents mimeType: mimeType filename: fileName
    self respond: [:url |
        (WAResponse new)
            contentType: mimeType;
            doNotCache;
            headerAt: 'Content-Disposition' put: 'attachment; 
filename="' , fileName , '"';
            headerAt: 'Content-length' put: contents size printString;
            contents: contents;
            yourself]

This download method is available as an extension to base seaside in 
repository  http://www.squeaksource.com/Jetsam

cheers

Keith


More information about the Seaside mailing list