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 回答
- 0 关注
- 2043 浏览
添加回答
举报
0/150
提交
取消