mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-04-25 09:04:48 +00:00
Use StreamingHttpResponse to server documents
This commit is contained in:
parent
f36836bc48
commit
918f286eea
1 changed files with 2 additions and 2 deletions
|
|
@ -1,6 +1,6 @@
|
|||
from django.shortcuts import get_object_or_404
|
||||
from django.http import HttpResponse
|
||||
from wsgiref.util import FileWrapper
|
||||
from django.http import StreamingHttpResponse
|
||||
|
||||
from wagtail.wagtaildocs.models import Document, document_served
|
||||
|
||||
|
|
@ -8,7 +8,7 @@ from wagtail.wagtaildocs.models import Document, document_served
|
|||
def serve(request, document_id, document_filename):
|
||||
doc = get_object_or_404(Document, id=document_id)
|
||||
wrapper = FileWrapper(doc.file)
|
||||
response = HttpResponse(wrapper, content_type='application/octet-stream')
|
||||
response = StreamingHttpResponse(wrapper, content_type='application/octet-stream')
|
||||
|
||||
# TODO: strip out weird characters like semicolons from the filename
|
||||
# (there doesn't seem to be an official way of escaping them)
|
||||
|
|
|
|||
Loading…
Reference in a new issue