Unable to serve video file

19 views
Skip to first unread message

Ephraim Anierobi

unread,
Aug 28, 2016, 5:13:10 AM8/28/16
to ko...@googlegroups.com
Please I have failed to serve a video file to browser.

In template I do this:
<a tal:attributes="href api.url(api.root, '@@download_video', query={'came_from': request.url,'url':context.video_url})" class="btn">Download</a>
My view function:
@view_config(name='download_video')
def dl(request):
    url = request.params.get('url')
    camefrom = request.params.get('came_from')
    path_dir = request.registry.settings['app.download_path']
    result= save_to_disk(url, path_dir)
    if result:
        filename = result['filename']
        filepath = os.path.abspath(os.path.join(path_dir,filename))
        file_exists = os.path.exists(filepath)
        if file_exists:
            res = FileResponse(filepath,content_type='video/mp4')
            res.headers['Content-Length'] = os.path.getsize(filepath)
            res.headers['Content-Disposition'] = 'attachment;filename=%s'%filename
            return res
    request.session.flash(_("Error downloading video, please check your network","danger"))
    return HTTPFound(location=camefrom)

davide moro

unread,
Aug 28, 2016, 10:31:23 AM8/28/16
to ko...@googlegroups.com

Hi,

what does mean "unable to serve video file"?

Please provide more info, stack trace errors, etc.

Cheers,

davide


--
You received this message because you are subscribed to the Google Groups "Kotti" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kotti+unsubscribe@googlegroups.com.
To post to this group, send email to ko...@googlegroups.com.
Visit this group at https://groups.google.com/group/kotti.
To view this discussion on the web visit https://groups.google.com/d/msgid/kotti/CAGQAffxDEPpHeq_1ZVBW2ZfAE%2BnnJk40ZKR18uy4s8O7o7wxxw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages