[Seaside] Making a download page

AA aa at serendip.demon.co.uk
Wed Mar 9 19:41:58 UTC 2011

I experimented exhaustively with this just recently; it simply doesn't work when I have files stored on my OS's native filesystem.  And I MUST apologise, because I didn't get around to filing a bug report.  (Sorry!)

First of all, there's no method forURIReturnSingleMimeTypeOrDefault:, which is called by MIMEDocument class >> guessTypeFromName: url, which is in turn called when trying to determine the file MIME type.

I did my downloads like this (note: 'aFile' is a MultiByteFileStream:):

	html anchor
		callback: [ self downloadFile: aFile ];
		with: aFile localName.

downloadFile: aFile
	self requestContext respond: [ :response |
			contentType: (MIMEType forFileNameReturnSingleMimeTypeOrDefault: aFile localName);
			attachmentWithFileName: aFile fullName;
			headerAt: 'X-Accel-Redirect'
			put: aFile name ]

I'm using nginx as my webserver, so the 'X-Accel-Redirect' is the equivalent for the standard 'X-SendFile' header.

Now, this worked nicely in the past, but since I've upgraded to the latest Seaside 3.0.4, I'm having some problems...  So right now I'm debugging to find out what's going on (could be a misconfigured webserver, of course).


On Wed, 9 Mar 2011 11:25:59 -0500
John McKeon <p3anoman at gmail.com> wrote:

> Ricardo,
>  You can use WAAnchorTag>>#document:mimeType:fileName: to render a download
> link.
> Have a look at the code for WAUploadFunctionalTest>>#renderDownloadLinksOn:
> to see how it is used.
> (If you look at the test in the browser, you will have to upload a file
> first before you will see the download links rendered)
> Hope this helps
> John

More information about the seaside mailing list