There is a request in that case, it's just that response.download is 
expecting (a) the last argument in the URL to be the name of a file, and 
(b) its second argument to be a db object. In this case, instead of 
response.download, use response.stream(file, chunk_size, request). 
See http://web2py.com/book/default/chapter/04#response.

Anthony

On Thursday, October 27, 2011 6:21:16 AM UTC-4, $p00ky wrote:
>
> Dear all,
>
> Is it possible to offer a file for downloading in web2py?
>
>         theFile = tempfile.NamedTemporaryFile()
>         with open(theFile.name, "wb") as myFile:
>             myFile.write("something")
>         return response.download(request, theFile)
>
> For instance, when a user goes to "mysite.com/myapp/default/download/text", 
> I return a file with "text" written in it.
> I would like to use a tempfile for that.
>
> There is no "request" here, so "return response.download(request, 
> theFile)" does not work.
> Any suggestion?
>

Reply via email to