|
Luca Montecchiani
l.montecchiani at teamsystem.com
Fri Feb 23 10:52:49 EST 2007
Use sendfile, there are examples in the mailing list
the only advice is to add those headers :
_stat = os.stat( file_path )
fsize = str(_stat.st_size)
req.headers_out["Content-Length"] = fsize
req.headers_out["Content-Disposition"] = "attachment; filename=%s" % \
os.path.basename(file_path)
req.sendfile(file_path)
bye,
luca
Lisický Jiří wrote:
> Hello,
>
> I am using mod_python publisher and I want send tar.gz file to
> client. File is not acessible by apache. I am using this code:
>
> def send_file(req):
> req.content_type = "application/x-gzip"
> file = open("/some/path/file.tar.gz").read()
> return file
>
> But problem is, that this file have name as python function, that send
> it with extension gz. So send_file.gz. And I need also tar extension.
>
> Is there better way, that copy this file to directory, where apache
> see it?
>
> BTW MSIE is also "very funny". If I get http://www/file.tgz MSIE save
> it as file.gz - so I must use tar.gz extension. (in firefox no problem)
>
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
--
Luca Montecchiani
Software Di Base
TeamSystem S.r.l.
------------------------------------------------------------------------------------------
Informativa ai sensi del D. Lgs. 196-30/06/2003.
Il contenuto di questa e.mail e degli eventuali allegati, deve essere
nella disponibilità
del solo destinatario. Se ricevete per errore questa e-mail siete
pregati di informarci
(rispedendola al mittente) e di provvedere alla sua rimozione.
Possono essere presenti informazioni riservate e non corrette
(parzialmente o totalmente).
Le e-mail in partenza e in arrivo possono essere oggetto di monitoraggio
da parte di Teamsystem spa. Del contenuto è responsabile il mittente
della presente.
Chiunque venga in possesso non autorizzato di questa e-mail è vincolato
dalla Legge a non leggerne il contenuto, a non copiarla, a non
diffonderla e a non usarla.
Informiamo che per l' esercizio dei diritti di cui all'art. 7 del
d.lgs.196/2003 ci si può
rivolgere al Titolare del trattamento Teamsystem S.r.l. via Gagarin 205
61100 PESARO
per posta o fax, indicando sulla busta o sul foglio la dicitura
"Inerente alla Privacy",
o inviando una e-mail all' indirizzo privacy at teamsystem.com .
------------------------------------------------------------------------------------------
|