class downMonth(View):
def get(self,request):
strTime1 = request.GET.get('time')
filepath = "{}/searchText/{}.zip".format( settings.BASE_DIR ,strTime1) # 文件所在位置
file = open(filepath, 'rb')
response = FileResponse(file)
response['Content-Disposition'] = 'attachment;filename="{}.{}"'.format(strTime1, "zip") # 文件名称和类型
return response
django 下载返回文件流
最新推荐文章于 2024-03-25 18:47:38 发布