Skip to content

Commit

Permalink
Merge branch 'croolicjah-download_fix'
Browse files Browse the repository at this point in the history
  • Loading branch information
zappycode committed Nov 25, 2020
2 parents 19138df + 1ee89f4 commit 0627a01
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions courses/views.py
@@ -1,7 +1,5 @@
from datetime import datetime

from django.contrib.auth.decorators import login_required
from django.http import HttpResponse
from django.http import HttpResponse, StreamingHttpResponse
from django.shortcuts import render, get_object_or_404

from .models import Lecture, Section, Course
Expand All @@ -24,7 +22,7 @@ def download_video(request, lecture_id):
file_name = str(lecture.vimeo_video_id) + '.mp4'
req = requests.get(lecture.download_url, stream=True, timeout=(5, 10))
if req.status_code == 200:
response = HttpResponse(req, content_type='video/mp4')
response = StreamingHttpResponse(req, content_type='video/mp4')
response['Content-Disposition'] = 'attachment; filename=' + str(file_name)
return response
else:
Expand Down

0 comments on commit 0627a01

Please sign in to comment.