标签:ati 文件下载 ref fir chunk name class string ESS
##上传文件
#setting配置
##文件下载
class Upload_file(APIView): def get(self,request): id =request.GET.get(‘id‘) query = Question.objects.filter(id = id).first() filename = query.accessory with open (filename,"rb") as file_object: response = HttpResponse(file_object) response[‘Content-Type‘] = ‘application/octet-stream‘ #设置头信息,告诉浏览器这是个文件 filename = ‘attachment; filename=%s‘%filename.split("\\")[6] #设置文件名的中文编码方式 response[‘Content-Disposition‘] = filename.encode(‘utf-8‘, ‘ISO-8859-1‘) return response
前端直接<a :href="‘http://127.0.0.1:8000/download_excel/?id=‘+ fileId">下载</a>
标签:ati 文件下载 ref fir chunk name class string ESS
原文地址:https://www.cnblogs.com/sunzhiqi/p/14115641.html