I'm guessing the problem is that response.download sets Content-Disposition
as an attachment. Make another controller function in default.py
def stream():
import re
from pydal.exceptions import NotAuthorizedException, NotFoundException
if not request.args:
raise HTTP(404)
name = request.args[-1]
items = re.compile('(?P<table>.*?)\.(?P<field>.*?)\..*').match(name)
if not items:
raise HTTP(404)
(t, f) = (items.group('table'), items.group('field'))
try:
field = db[t][f]
except AttributeError:
raise HTTP(404)
try:
(filename, stream) = field.retrieve(name, nameonly=True)
except NotAuthorizedException:
raise HTTP(403)
except (NotFoundException, IOError):
raise HTTP(404)
return response.stream(stream)
Note that this function could be made a lot simpler but I wanted it to work
with uploadseparate=True and to work for any kind of file you want to
stream.
Now replace "download" with "stream" in your URL and you're done.
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.