Re: [Zope] Content Disposition - Download files
Bruno Grampa wrote at 2006-6-26 12:46 +0200: >i want to send an image or a pdf to a browser not for viewing but for >downloading. >I've written this code: >'application/force-download')"> >filename=filename.gif')"> You add an additional '' It might be necessary to avoid white space around your tags. Therefore, it is better to do this in a Python Script rather than a DTML object. There, it would look like: r = container.REQUEST; R = r.RESPONSE R.setHeader(...) # your additional headers ... return context.index_html(r, R) -- Dieter ___ 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] Content Disposition - Download files
Hi, On Monday 26 June 2006 12:46, Bruno Grampa wrote: > Hello, > i want to send an image or a pdf to a browser not for viewing but for > downloading. > I've written this code: > 'application/force-download')"> > filename=filename.gif')"> > > now i have to send the file as a binary flow, but i don't know how to > do. Can you help me? 'attachment;filename=filename.gif')" > But there is no reason why you wouldn't want to do that with a Python script. HTH ___ 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] Content Disposition - Download files
context.REQUEST.RESPONSE.setHeader('Content-Disposition','attachment; filename=%s' % context.getId()) Nice idea, but what i need is different. In PHP there is a function called readfile, i'm sure there is something also in Zope, but i'm not able to find it! No, I can tell you you are on the wrong path. Zope isnt PHP. Dont try to follow old PHP patterns with Zope. (Of course you could read the file object data but this inefficient) What is the problem with above solution? Regards Tino ___ 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] Content Disposition - Download files
Bruno Grampa wrote: now i have to send the file as a binary flow, but i don't know how to do. Can you help me? Maybe if you stop torturing yourself (and us!) with dtml. The above should be either an external method, or a method of a content object from a product. cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk ___ 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] Content Disposition - Download files
Hello, >> i want to send an image or a pdf to a browser not for viewing but for >> downloading. >> I've written this code: >> > 'application/force-download')"> >> > filename=filename.gif')"> >> >> now i have to send the file as a binary flow, but i don't know how to >> do. Can you help me? > Do you plan to always send the file for download? > Then you just put a script name into "precondition" > field of the object. The script could be something > like: > > (Python script) > > context.REQUEST.RESPONSE.setHeader('Content-Disposition','attachment; > filename=%s' % context.getId()) Nice idea, but what i need is different. In PHP there is a function called readfile, i'm sure there is something also in Zope, but i'm not able to find it! Thanks, Bruno ___ 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] Content Disposition - Download files
Bruno Grampa schrieb: Hello, i want to send an image or a pdf to a browser not for viewing but for downloading. I've written this code: now i have to send the file as a binary flow, but i don't know how to do. Can you help me? Do you plan to always send the file for download? Then you just put a script name into "precondition" field of the object. The script could be something like: (Python script) context.REQUEST.RESPONSE.setHeader('Content-Disposition','attachment; filename=%s' % context.getId()) Regards Tino Wildenhain ___ 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 )
[Zope] Content Disposition - Download files
Hello, i want to send an image or a pdf to a browser not for viewing but for downloading. I've written this code: now i have to send the file as a binary flow, but i don't know how to do. Can you help me? Thanks, Bruno ___ 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 )