Re: Re: [Zope] download a file in a specific folder in the filesystem
At Thursday 24/8/2006 12:52, Alan wrote:
But for what I want LocalFS or ExtFile sounds too much, specially because I just need to download. Either, I did not realise yet well what Richard purposed... However, I tried that:
with a external method fname = os.path.join(jobdir,'results.zip') file = open(fname,'rb').read() return file
but instead of having the file downloaded, it is printed in my browser, as if it was a ascii file. I guess I need to add a mime type property here, but I am running out of ideas.
Exactly. Something like: REQUEST.RESPONSE.setHeader('Content-Type', 'application/zip-compressed') (uhm, not sure of the right spelling) And return the file object, not its contents. The publisher takes care of sending it on chunks if needed. Gabriel Genellina Softlab SRL __________________________________________________ Pregunt�. Respond�. Descubr�. Todo lo que quer�as saber, y lo que ni imaginabas, est� en Yahoo! Respuestas (Beta). �Probalo ya! http://www.yahoo.com.ar/respuestas
Thanks a lot guys, it's working fine. elif (func == 'Download'): fname = os.path.join(jobdir,'results.zip') file = open(fname,'rb').read() self.REQUEST.RESPONSE.setHeader('Content-Type', 'application/zip') return file Cheers, Alan On 24/08/06, Gabriel Genellina <gagsl-zope@yahoo.com.ar> wrote:
At Thursday 24/8/2006 12:52, Alan wrote:
But for what I want LocalFS or ExtFile sounds too much, specially because I just need to download. Either, I did not realise yet well what Richard purposed... However, I tried that:
with a external method fname = os.path.join(jobdir,'results.zip') file = open(fname,'rb').read() return file
but instead of having the file downloaded, it is printed in my browser, as if it was a ascii file. I guess I need to add a mime type property here, but I am running out of ideas.
Exactly. Something like: REQUEST.RESPONSE.setHeader('Content-Type', 'application/zip-compressed') (uhm, not sure of the right spelling) And return the file object, not its contents. The publisher takes care of sending it on chunks if needed.
Gabriel Genellina Softlab SRL
__________________________________________________ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas
-- Alan Wilter S. da Silva, D.Sc. - Research Associate Department of Biochemistry, University of Cambridge. 80 Tennis Court Road, Cambridge CB2 1GA, UK.
participants (2)
-
Alan -
Gabriel Genellina