问题描述
我有一个 Flask 应用程序,可以流式传输我存储在 mongodb 数据库中的视频。它在 Firefox 桌面上运行良好,但在我重新加载页面之前不允许在 chrome 桌面上擦洗。它甚至在移动设备上根本不起作用,它只是什么都不返回。这是我的代码。
@app.route('/view/<postid>')
def Rview(postid):
post_id_obj = ObjectId(postid)
cur_post = col_posts.find_one({"_id": post_id_obj})
if str(cur_post) == 'None':
return render_template('error.html',head='No post found')
else:
location = cur_post['file'] # gets the file location from the database,stored using fs chunks
file_mimetype = cur_post['mimetype']
file_ext = '.' + file_mimetype.split("/")[1]
if file_mimetype == "video/mp4":
return send_file(BytesIO(fs.get(location).read()),mimetype=file_mimetype,as_attachment=False,attachment_filename=(str(random.randint(10000000,99999999)) + file_ext))
else:
return send_file(BytesIO(fs.get(location).read()),99999999)) + file_ext))
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)