[英]Django download files errors “zip file is invalid”
Here is my view code to download a file 这是我下载文件的视图代码
def download_order(request,order_id):
purchase=GigPurchase.objects.select_related().get(order_id=order_id)
order=purchase.order
wrapper=FileWrapper(open(order.path,"rb"))
content=mimetypes.guess_type(order.path)[0]
t=purchase.gig.title
title=slugify(t)
response=HttpResponse(wrapper,content_type=content)
response['Content-Disposition']='attachment;filename=%s.zip'%(title)
return response
I have a model that has a file field named "order". 我有一个具有名为“ order”的文件字段的模型。 What am i doing wrong here because when I click on the link.
我在这里做错了什么,因为当我单击链接时。 I get the download file but when I try to open it I get "The compressed zip folder is invalid".
我得到下载文件,但是当我尝试打开它时,得到“压缩的zip文件夹无效”。 Please help.
请帮忙。 Thanks
谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.