def download(request, submission_id):
submission = TaskSubmission.objects.get(pk=submission_id)
file_name = '{0!s}_{1!s}_{2!s}'.format(submission.task.slug,
submission.user.username,
submission_id)
path = smart_str(submission.get_submission_path())
response = HttpResponse(content_type='application/force-download')
response['Content-Disposition'] = 'attachment; filename={0!s}'.format(
smart_str(file_name))
response['X-Sendfile'] = path
response['X-Accel-Redirect'] = get_submission_uri_from_path(path)
return response
评论列表
文章目录