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 [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
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 <[hidden email]> wrote: Hi, _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
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 <[hidden email]> You can put downloadable content in a file library or serve directly from the file system via the webserver w/o going through Seaside. _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Cheers, Bob On 12/18/10 10:46 AM, alexandre bp wrote:
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by Alexandre BP
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 <[hidden email]> wrote:
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Bob Nemec
|
In reply to this post by Alexandre BP
Here's an approach:
1. Create an external directory you want to share 2. Tell seaside where it is: | mylib | mylib := WAExternalFileLibrary new. mylib preferenceAt: #directory put: '/downloadable'. "<--- absolute path you your directory" mylib preferenceAt: #listing put: true. WADispatcher default register: mylib at: 'mystuff' 3. Put a link that point to the file you want the user to download: html anchor url: '/mystuff/filenumber1'; type: ( WAMimeType new main: 'text'; sub: 'csv'); with: 'text for anchor'. 4. Or a link that let's them download any file in the directory: html anchor url: '/mystuff/'; with: 'text for anchor'. Cheers, Bob On 12/18/10 10:46 AM, alexandre bp wrote:
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by Alexandre BP
2010/12/17 alexandre bp <[hidden email]>:
> 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? For production deployments we recommend configuring Apache to serve the files: http://book.seaside.st/book/advanced/deployment/deployment-apache/serving-files It's a bit of work to set up but very reliable, fast and doesn't put any load on your Smalltalk image. Cheers Philippe _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by Bob Nemec
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. <[hidden email]> Here's some old code that I've been using. There may be a more current option. _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
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:
[
fileWriter handleFile: row nameOfCollection from: row.
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 #streamI 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 Thank you for your time. alex 2010/12/18 alexandre bp <[hidden email]> Thx a lot everyone I think I have got what I need to understand how it works. _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Free forum by Nabble | Edit this page |