[Seaside] Serving files from within Seaside
Jon Paynter
kittle31 at gmail.com
Tue Dec 18 18:10:07 UTC 2012
>
> > Hi there,
> >
> > I know people consider serving files a job that should be handled by a
> > "real" http server rather than Seaside. In most cases, esp. for static
> > resources that can be accessed by the public, that is absolutely the
> case.
> >
> > But I need to serve files in a callback. The files are being partly
> > calculated and read from a DB and should be available for download by
> > clicking on a link.
> >
> > I've been looking into WAFileLibrary and WAFileHandler, but am not sure
> > where to start.
> >
> > What I want to do is something like:
> >
> > html anchor
> > callback: [self calculateChartAndServeIt]
> > with: 'Download full chart'.
> >
> > I know I will have to respond:, but can I do that in a callback?
> >
> > Joachim
>
I do a very similar thing in my application. Generate a file and serve it
up to the user. So far this has worked well:
downloadtext: contents named: aFilename
"trigger a file download operation for aFilename with the contents in
contents"
self requestContext respond: [ : response |
response contentType: 'text/plain';
attachmentWithFileName: aFilename;
nextPutAll: contents.
].
where "contents" is a string containing the text of the file to download
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20121218/b5c4fd38/attachment.htm
More information about the seaside
mailing list