[Seaside] Downloadable content

Bob N. bobn at rogers.com
Sat Dec 18 17:07:27 UTC 2010


Here's some old code that I've been using.  There may be a more current
option.
---
In the 'download file' callback method...
byteArray := [path asFilename contentsOfEntireBinaryFile]
on: Error
do: [:ex | ex description].
byteArray isString ifTrue: [^self parent prompt: byteArray title: 'Error
reading: ', path asString].

self session
downloadBinary: byteArray
mimeType: (WAFileLibrary mimetypeFor: self fileSuffix)
filename: filename
---
(my session class)>>downloadBinary: aContents mimeType: aMimeType filename:
aFileName

self requestContext respond: [:response |
response
contentType: aMimeType;
binary;
nextPutAll: aContents;
doNotCache;
attachmentWithFileName: aFileName;
headerAt: 'Content-length' put: aContents size printString;
yourself]


On Sat, Dec 18, 2010 at 10:46 AM, alexandre bp <abalonpe at ulb.ac.be> wrote:

> Thank you for you reply.
> yes but the problem is that I don't understand how to give the file to the
> client from the file library....
> It must be very stupid but I have never done it  (even in PHP)  so I have
> no clue...
> cheers
> alex
>
> 2010/12/17 Sean Allen <sean at monkeysnatchbanana.com>
>
>> You can put downloadable content in a file library or serve directly from
>> the file system via the webserver w/o going through Seaside.
>>
>> On Fri, Dec 17, 2010 at 12:10 PM, alexandre bp <abalonpe at ulb.ac.be>wrote:
>>
>>> Hi,
>>>
>>> I'd like to add a downloadable content on my website and I don't have any
>>> idea how to do that.
>>> I saw the fileUpload method in the WARenderCanvas to upload a file on the
>>> server but I don't find anything to download a file from it...
>>> Where should I put the downloadable file and how to export it to the
>>> computer of the client?
>>>
>>> Thx in advance,
>>>
>>> alex
>>>
>>> _______________________________________________
>>> seaside mailing list
>>> seaside at lists.squeakfoundation.org
>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>
>>>
>>
>> _______________________________________________
>> seaside mailing list
>> seaside at lists.squeakfoundation.org
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
>>
>
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20101218/387b62aa/attachment-0001.htm


More information about the seaside mailing list