only pdf to browser - inline
def doc2user():
import os
prn_id = request.args(0,cast=int)
task = db.zurina(prn_id) or error()
qu=db.zurina.id == prn_id
res= db(qu).select().first()
upfolder= os.path.join(request.folder, 'docfiles')
file_path = os.path.join( upfolder, res.new_image_file)
ext = os.path.splitext( res.jenka_fnm )
with open(file_path, 'rb') as f:
file_text= f.read()
from gluon.contenttype import contenttype
if len(ext) and len(ext[1]):
response.headers['Content-Type'] = contenttype(ext[1])
else:
response.headers['Content-Type'] =
contenttype('application/octet-stream')
if len(ext) and len(ext[1]) and ext[1].endswith('pdf'):
response.headers['Content-disposition'] = 'inline;
filename=\"%s"' % ( res.jenka_fnm)
else:
response.headers['Content-disposition'] = 'attachment;
filename=\"%s"' % ( res.jenka_fnm)
четверг, 24 сентября 2020 г., 17:54:53 UTC+3 пользователь
[email protected] написал:
>
> Hi,
> i have a controller with this :
> response.headers['Content-Disposition'] = 'inline; filename=%s' %
> request.vars.filename
>
> to force streaming the pdf file , and i do not why it does not work ..
> any idea ?
>
> Thank you
>
>
>
--
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/f388deff-6ab2-42ab-91a4-08ae69a7828co%40googlegroups.com.