courses = get_courses(request.user)
document = Document.objects.get(pk=pk)
if get_access(document, courses):
- fsock = open(document.file.path.encode('utf8'), 'r')
- mimetype = mimetypes.guess_type(document.file.path)[0]
- extension = mimetypes.guess_extension(mimetype)
- response = HttpResponse(fsock, mimetype=mimetype)
- response['Content-Disposition'] = "attachment; filename=%s%s" % \
- (document.title.encode('utf8'), extension)
- return response
+ return serve_media(document.file.path.encode('utf8'), streaming=False)
+ #fsock = open(document.file.path.encode('utf8'), 'r')
+ #mimetype = mimetypes.guess_type(document.file.path)[0]
+ #extension = mimetypes.guess_extension(mimetype)
+ #response = HttpResponse(fsock, mimetype=mimetype)
+ #response['Content-Disposition'] = "attachment; filename=%s%s" % \
+ # (document.title.encode('utf8'), extension)
+ #return response
else:
return redirect('teleforma-home')
courses = get_courses(request.user)
document = Document.objects.get(pk=pk)
if get_access(document, courses):
- fsock = open(document.file.path.encode('utf8'), 'r')
- mimetype = mimetypes.guess_type(document.file.path)[0]
- extension = mimetypes.guess_extension(mimetype)
- response = HttpResponse(fsock, mimetype=mimetype)
- return response
+ return serve_media(document.file.path.encode('utf8'), streaming=True)
+ #fsock = open(document.file.path.encode('utf8'), 'r')
+ #mimetype = mimetypes.guess_type(document.file.path)[0]
+ #extension = mimetypes.guess_extension(mimetype)
+ #response = HttpResponse(fsock, mimetype=mimetype)
+ #return response
else:
return redirect('teleforma-home')