[Seaside] How to set the mime-type of a response?

Brian Brown rbb at techgame.net
Wed Oct 15 12:02:35 CEST 2003


On Wednesday, Oct 15, 2003, at 10:31 America/Denver, Ian Prince wrote:

> Hello All,
>
> I have been following Seaside since 0.91 and it reminds me of Bobo 
> back in 1998 before it became Zope - wonderfully simple and elegant.
>
> Anyway here's my first question: I am trying to return the contents of 
> a file read from disk (or created on the fly) but can't find out how 
> to set its mime-type.
>
> In Zope/DTML I think this would be as follows for a PDF document:
>
> 	<dtml-call "RESPONSE.setHeader('Content-Type', 'application/pdf')">
>

This cracks me up :-) I used to do that as well.


> How can I do this in Seaside (I'm using Seaside2.3b5.st)?

I think you should check out WAFile, and I have also implemented an 
asMIMEDocument message on custom  images and audio files looking 
something like this:

asMIMEDocument
	^ MIMEDocument contentType: 'image/jpeg' content: self contents


You could do exactly the same thing... the text of a pdf document in an 
ivar, and just change the above mime type to 'application/pdf'. You 
would call it like this:

myPDFCollection do:
	[:ea  |
	html anchorWithAction: [self answer: ea] text: ea pdfName]

...assuming your PDF object had a pdfName method.

Anyway, I hope that helps.

Brian


> My apologies if I'm missing something very obvious.
>
> Thanks in advance,
>
> Ian.
>
> --
> ian prince - inextenso - 1 ruelle des moulins - 1260 nyon - switzerland
> ian at inextenso.com - tel +41 22 990 10 80 - mobile +41 78 880 27 02
>
> _______________________________________________
> Seaside mailing list
> Seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/listinfo/seaside



More information about the Seaside mailing list