[Zope] Setting filename of files to be downloaded

Ulla Theiss u.theiss at eurodata.de
Mon Nov 6 10:02:56 EST 2006


Dear Mailinglist-Members,

we have a problem with the filename for files downloaded from our site.

The files downloaded are dynamically generated. Therefore we have a 
product with a method "displayfile" which is called for each file to be 
downloaded.

It is like that:

def displayFile(self, ... some arguments ... , REQUEST, RESPONSE = None):

    content =   # generate a file somehow
    fileType, enc = guess_content_type(filename, content, REQUEST)
    RESPONSE.setHeader('Content-Type', fileType)
return content


The Problem is, that the file to be downloaded always is called displayFile.
According the the content-type it is sometimes called displayFile.pdf, 
displayFile.txt, displayFile.tif, etc.

But we need it to name according to the content some time hugo.pdf and 
another time Thomas.txt, ..

How is it possible to change the filename? Do I perhaps  have to set 
another header-entry in the response-object?

Many thanks in advance,
Ulla.




More information about the Zope mailing list