[Zope] download a file in a specific folder in the filesystem
Dears, I would to know how to download a file generated by a program outside zope. I mean, I would like to download a file via zope webserver and such a file is located outside the zope space. Since zope treats everything as a object I have know idea of how importing the link to a file inside zope space. I would thank in advance any help. Cheers, Alan -- Alan Wilter S. da Silva, D.Sc. - Research Associate Department of Biochemistry, University of Cambridge. 80 Tennis Court Road, Cambridge CB2 1GA, UK. http://www.bio.cam.ac.uk/~awd28 ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] download a file in a specific folder in the filesystem
If you just want the file to be downloadable from say a web page served by zope you could make an object on your zope system (say a page template) that renders a page with a link to the file you wish to make available. The file would have to accessible to your web server. On 24 Aug 2006, at 16:00, Alan wrote:Dears,I would to know how to download a file generated by a program outside zope.I mean, I would like to download a file via zope webserver and such afile is located outside the zope space. Since zope treats everythingas a object I have know idea of how "importing" the link to a fileinside zope space.I would thank in advance any help.Cheers,Alan-- Alan Wilter S. da Silva, D.Sc. - Research AssociateDepartment of Biochemistry, University of Cambridge.80 Tennis Court Road, Cambridge CB2 1GA, UK. http://www.bio.cam.ac.uk/~awd28 ___Zope maillist - Zope@zope.orghttp://mail.zope.org/mailman/listinfo/zope** No cross posts or HTML encoding! **(Related lists - http://mail.zope.org/mailman/listinfo/zope-announcehttp://mail.zope.org/mailman/listinfo/zope-dev ) Richard Phelps Senior Lecturer in Nephrology Renal Autoimmunity Group, MRC Centre for Inflammation Research, The Queen's Medical Research Institute 47 Little France Crescent Edinburgh EH16 4TJ Tel (44) 131 242 9164 Fax (44) 131 242 9168 ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: Re: [Zope] download a file in a specific folder in the filesystem
Hi! Thanks for your replies. 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. Any commentary would be very welcome. Cheers, Alan On 24/08/06, Richard Phelps [EMAIL PROTECTED] wrote: If you just want the file to be downloadable from say a web page served by zope you could make an object on your zope system (say a page template) that renders a page with a link to the file you wish to make available. The file would have to accessible to your web server. On 24 Aug 2006, at 16:00, Alan wrote: Dears, I would to know how to download a file generated by a program outside zope. I mean, I would like to download a file via zope webserver and such a file is located outside the zope space. Since zope treats everything as a object I have know idea of how importing the link to a file inside zope space. I would thank in advance any help. Cheers, Alan -- Alan Wilter S. da Silva, D.Sc. - Research Associate Department of Biochemistry, University of Cambridge. 80 Tennis Court Road, Cambridge CB2 1GA, UK. http://www.bio.cam.ac.uk/~awd28 ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev ) Richard Phelps Senior Lecturer in Nephrology Renal Autoimmunity Group, MRC Centre for Inflammation Research, The Queen's Medical Research Institute 47 Little France Crescent Edinburgh EH16 4TJ Tel (44) 131 242 9164 Fax (44) 131 242 9168 -- Alan Wilter S. da Silva, D.Sc. - Research Associate Department of Biochemistry, University of Cambridge. 80 Tennis Court Road, Cambridge CB2 1GA, UK. http://www.bio.cam.ac.uk/~awd28 -- Alan Wilter S. da Silva, D.Sc. - Research Associate Department of Biochemistry, University of Cambridge. 80 Tennis Court Road, Cambridge CB2 1GA, UK. http://www.bio.cam.ac.uk/~awd28 ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: Re: [Zope] download a file in a specific folder in the filesystem
- Original Message - From: Alan [EMAIL PROTECTED] To: zope@zope.org Sent: Thursday, August 24, 2006 11:52 AM Subject: Re: Re: [Zope] download a file in a specific folder in the filesystem Hi! Thanks for your replies. 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. Try googling: response.setheader content-type response.setheader content-disposition Jonathan ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
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 ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: Re: Re: [Zope] download a file in a specific folder in the filesystem
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 [EMAIL PROTECTED] 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. http://www.bio.cam.ac.uk/~awd28 ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: Re: Re: [Zope] download a file in a specific folder in the filesystem
At Thursday 24/8/2006 13:55, Alan wrote: 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 Better use 'application/x-zip-compressed' and perhaps: REQUEST.RESPONSE.setHeader('Content-Disposition', 'attachment; filename=suggested-filename.zip') 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 ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )