描述:Flask返回文件数据流使用send_file,过程中发现指定的中文名称文件名会被过滤掉
send_file(file_path, as_attachment=True, attachment_filename=filename)
file_path:文件路径
attachment_filename:指定文件名
- 解决:转换文件名编码,在返回的响应头指定编码格式
filename = quote(file_name)
rv.headers['Content-Disposition'] += "; filename*=utf-8''%s" % (filename)
return rv