[Twisted-web] Nevow-Stan How to save file?
Maarten ter Huurne
maarten at treewalker.org
Thu Mar 13 18:35:28 EDT 2008
On Thursday 13 March 2008, Suha Onay wrote:
> How is it possible to set the HTTP header of the link to this file
> (qqq.lqp )?
>
> f= open(os.path.join(LQS.WEB_SERVER, 'xxx', 'qqq.lqp'), 'w')
> f.write(fileInput)
> f.close()
>
> return [
> T.a(href="/xxx/qqq.lqp")['Save'],
> webform.renderForms()[FORM_LAYOUT],
> ]
The HTTP header cannot be set on the link; the header should be set when
serving the file download. This is just a matter of calling setHeader() on
the request. I'm not very familiar with Nevow, so I don't know where that
call should be placed.
By the way, instead of generating a file on the server and offering that for
download, it might be simpler to send the data directly to the client. That
way you don't have to worry about uniqueness of file names, cleaning up
files when they are no longer needed etc.
Bye,
Maarten
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part.
Url : http://twistedmatrix.com/pipermail/twisted-web/attachments/20080313/9f9e872e/attachment.pgp
More information about the Twisted-web
mailing list