[Seaside] Downloadable content
alexandre bp
abalonpe at ulb.ac.be
Sat Dec 18 22:26:47 UTC 2010
A last question concerning my problem :s
I'd like to create a file and to send it to the client when he clicks on a
link (only one click for both actions).
Here is what I tried:
(html anchor)
callback:
[
[
"write in a file and save it on the server's harddisk"
fileWriter handleFile: row nameOfCollection from: row.
"get the content of the previously created file and send it to the client"
contents := fileLibrary documentForFile: row nameOfCollection ,
'.xml'.
self session
returnResponse: (WAResponse new document: contents mimeType:
'text/xml' fileName: row nameOfCollection).
parent warning: 'The file has been exported to your computer' ]
on: FileExistsException
do: [ :exception | parent warning: exception messageText ] ];
with: 'export'.
I get the following error: WAError: My subclass should have overridden
#stream
I don't really understand WAResponse, it seams the documentation is
out-of-date.
For example the following code is in the seaside book (
http://www.seaside.st/documentation/faq/how-to) and doesn't work anymore
because the method "document:mimeType:fileName:" is now on the instance
side...
Is there a convenient way to make the document be created after the link is
clicked?
Yes, this is a common problem. One solution is to create an anchor and
redirect:
html anchor
callback: [
self session returnResponse: (WAResponse
document: anObject
mimeType: aMimeType
fileName: aString) ];
with: 'Export'.
Thank you for your time.
alex
2010/12/18 alexandre bp <abalonpe at ulb.ac.be>
> Thx a lot everyone I think I have got what I need to understand how it
> works.
> I have already written exactly what I want thx to you. :-)
> cheers
> alex
>
> 2010/12/18 Bob N. <bobn at rogers.com>
>
> 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
>>>
>>>
>>
>> _______________________________________________
>> 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/9a806e04/attachment-0001.htm
More information about the seaside
mailing list