[Seaside] How to set the filename of a returned document?

Ian Prince ian at inextenso.com
Fri Oct 31 13:01:45 CET 2003


Thanks Avi, your suggestion works fine.

My naive implementation passes fileName down the following method chain:

WAHtmlRenderer>>anchorWithDocument: anObject mimeType: mimeType 
fileName: fileName text: aString
WAHtmlRenderer>>openAnchorWithDocument: anObject mimeType: mimeType 
fileName: fileName
WAHtmlRenderer>>urlForDocument: anObject mimeType: mimeType fileName: 
fileName
WADocumentHandler>>document: anObject mimeType: mimeType fileName: 
fileName

FWIW, the body of the final method looks like this:

	document := anObject.
	response := WAGenericResponse document: anObject mimeType: mimeType.
	response headerAt: 'Content-Disposition' put: 'attachment; 
filename=',fileName

Avi, you mentioned submitting the code back via Monticello. How would I 
go about this? Is there a HOW-TO hiding somewhere?

Thanks,

Ian.


On Vendredi, oct 31, 2003, at 20:54 Europe/Zurich, Avi Bryant wrote:

>
> On Wednesday, October 29, 2003, at 08:22 AM, Ian Prince wrote:
>
>> My application returns pdf files with:
>>
>> MyComponent>>renderContentOn: html
>> 	html anchorWithDocument: contents
>> 				mimeType: 'application/pdf'
>> 				text: 'download'.
>>
>> The pdf  files returned have names based on the session ids, e.g. 
>> @kMhhyhwLYiKxjcRl
>>
>> How can I go about  setting the filename of the returned document to 
>> something else, such as "generated_document.pdf"?
>
> You can do this with a header:
>
> Content-Disposition: attachment; filename=generated_document.pdf
>
> You would need to change WADocumentHandler>>response to optionally add 
> this header, probably based on a 'filename' ivar.  You'd then want to 
> add a variation of the #anchorWithDocument:... methods that set 
> #filename:.
>
> Send me a patch (or better, a .mcz) if you give it a shot, and I'll 
> merge it in.  If you get lost, let me 
> know._______________________________________________
> Seaside mailing list
> Seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/listinfo/seaside



More information about the Seaside mailing list