the first thing is: when you navigate to mycontroller/mydownload (no ajax)
can you get the file downloaded ?
second thing missing from your code: if you want the content downloaded as
an attachment, set the content-disposition header to attachment;
filename=afilename.tar
On Thursday, October 18, 2012 8:09:09 AM UTC+2, weheh wrote:
>
> Is it possible to do a response.stream in the middle of an ajax callback?
>
> I want to give users a button, which if pressed, will tar up all their
> files and initiate a download. Something like this:
>
> TAG.BUTTON(..., _onclick="ajax("%s", [], ':eval');" %
> URL(c='mycontroller', f='mydownload'))
>
> Then later, in mycontroller.py,
>
> def mydownload():
> ... create tarfile ...
> return response.stream(tarfile, attachment=True)
>
> I tried it, but (perhaps obviously to some) it doesn't work. So, how to
> get the mydownload() action to cause the browser to download the tarfile?
>
--