为了账号安全,请及时绑定邮箱和手机立即绑定

python下载优秀作业的例子,前端老是无法正常下载

python下载优秀作业的例子,前端老是无法正常下载

    file_path = os.path.join(settings.COURSE_RELATED, str(courseid), 'courseware', '课件.zip')         if os.path.exists(file_path):             with open(file_path, "rb") as file_zip:                 data = file_zip.read()             response = HttpResponse(data, content_type='application/zip;charset=utf-8')             response['Content-Disposition'] = 'attachment; filename=kejian.zip'             return response             # response = StreamingHttpResponse(file_iterator(file_path))             # response['Content-Type'] = 'application/octet-stream'             # response['Content-Disposition'] = 'attachment;filename="{0}"'.format('kejian')             # return response         else:             return Response({'error_no': -1, 'userinfo': True, 'error_msg': "该课程没有课件哦"})     else:         return Response({'error_no': -1, 'error_msg': "参数错误"}) except:     return Response({'error_no': -1, 'error_msg': "下载出错,稍后再试"})
查看完整描述

1 回答

?
pardon110

TA贡献1038条经验 获得超227个赞

请先行阅读提问的艺术

查看完整回答
反对 回复 2018-08-23
  • 1 回答
  • 0 关注
  • 1989 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信