I want to download generated data to a file on the users computer when they press a button. The button will call a python script which will generate the data. I'm not sure how to get the browser to bring up a download dialog and not just display the data. I am trying this. data = 'This is the data that is generated.' context.REQUEST.RESPONSE.setHeader('Content-Type', 'application/data') context.REQUEST.RESPONSE.setHeader('Content-Length', len(printed)) context.REQUEST.RESPONSE.setHeader('Content-Disposition', 'inline;filename=Data.dat') return data This display the data in the browser, but doesn't download it. Can someone help??? Thanks, Bruce.
Shouldn't the content type be set to 'application/octet-stream'? Eric Balasbas Senior Developer eric@virtosi.com http://www.virtosi.com/ Virtosi Ltd. Design -- Branding -- Zope On Tue, 29 May 2001, Bruce Pearson &/or Gwyn Ingham wrote:
I want to download generated data to a file on the users computer when they press a button.
The button will call a python script which will generate the data. I'm not sure how to get the browser to bring up a download dialog and not just display the data.
I am trying this.
data = 'This is the data that is generated.'
context.REQUEST.RESPONSE.setHeader('Content-Type', 'application/data') context.REQUEST.RESPONSE.setHeader('Content-Length', len(printed)) context.REQUEST.RESPONSE.setHeader('Content-Disposition', 'inline;filename=Data.dat') return data
This display the data in the browser, but doesn't download it.
Can someone help???
Thanks,
Bruce.
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Thanks for the help. The solution I found was: data = 'This is the data that is generated.' context.REQUEST.RESPONSE.setHeader('Content-Type', 'application/download') context.REQUEST.RESPONSE.setHeader('Content-Length', len(data)) context.REQUEST.RESPONSE.setHeader('Content-Disposition', 'attachment;filename=Data.dat') return data Thanks again, Bruce.
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Bruce Pearson &/or Gwyn Ingham Sent: Tuesday, 29 May 2001 12:25 PM To: Zope Subject: [Zope] Help on downloading data to a file
I want to download generated data to a file on the users computer when they press a button.
The button will call a python script which will generate the data. I'm not sure how to get the browser to bring up a download dialog and not just display the data.
I am trying this.
data = 'This is the data that is generated.'
context.REQUEST.RESPONSE.setHeader('Content-Type', 'application/data') context.REQUEST.RESPONSE.setHeader('Content-Length', len(printed)) context.REQUEST.RESPONSE.setHeader('Content-Disposition', 'inline;filename=Data.dat') return data
This display the data in the browser, but doesn't download it.
Can someone help???
Thanks,
Bruce.
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (2)
-
Bruce Pearson &/or Gwyn Ingham -
Eric Balasbas