from urllib.parse import quote #将中文进行URL 编码
@router.get("/template-file/download", summary="考评对象模板下载")
def template_file(request):
file_name = "考评对象导入模板.xlsx"
file_path = os.path.join(BASE_DIR, "static", file_name)
if not os.path.exists(file_path):
raise HttpError(404, "文件不存在!")
response = FileResponse(open(file_path, "rb"))
response['Content-Type'] = 'application/octet-stream'
response['Content-Disposition'] = "attachment;filename={}".format(quote(file_name))
return response
django-ninjia 下载文件显示中文名称
最新推荐文章于 2024-07-17 11:32:34 发布