[mod_python] req.sendfile(): specifying a name for the file sent?

Calvin Chen calvin.chen at gmail.com
Mon May 9 17:20:34 EDT 2005


Hello,

Right now, when I use req.sendfile(), the file download prompt comes
up and asks me if I want to download a file. So far so good. The
contents of this file is exactly how I wanted it to be. So far so
good.

I have this code in example.py:

---------
def index(req):
   req.content_type='text/file'
   req.sendfile('PATH_TO_FILE/name.txt')
---------

When the file is sent to the user, the file's default name is the URI
(ie 'example'), and I'd like to specify the filename, for example,
'name.txt' instead of 'example.'

Any ideas?

Thanks,
Calvin



More information about the Mod_python mailing list