Thank you for your email, it does not work for me, coud you detail the use
please


Le ven. 25 sept. 2020 à 11:30, Alex Beskopilny <[email protected]> a écrit :

> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/F7nWHxb_6OI/unsubscribe.
> To unsubscribe from this group and all its topics, 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
> <https://groups.google.com/d/msgid/web2py/f388deff-6ab2-42ab-91a4-08ae69a7828co%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Laurent Chambon <[email protected]>*
*47 rue Pougnet*
*33400 Talence*

*06 64 13 71 16  *

-- 
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/CAA-7DRuempGbV1u4k1Hmrxoar4R3eXWvKCx%2BQ1v9sb1PZMUF4g%40mail.gmail.com.

Reply via email to