Skip to content
Snippets Groups Projects
Commit d4b107a8 authored by Rafael László's avatar Rafael László :speech_balloon:
Browse files

mime types from python

parent 2766fdd1
No related branches found
No related tags found
1 merge request!2Dev
......@@ -6,6 +6,7 @@ from rest_framework.parsers import JSONParser, MultiPartParser
from django.http import HttpResponse, Http404
from rest_framework.decorators import action
import os
import mimetypes
class DocumentViewSet(viewsets.ModelViewSet):
......@@ -56,7 +57,7 @@ class DocumentViewSet(viewsets.ModelViewSet):
with document.file.open() as fh:
response = HttpResponse(
fh.read(),
content_type="application"
content_type=mimetypes.guess_type(document.file.name)
)
response['Content-Disposition'] = \
'inline; filename=' + os.path.basename(document.file.name)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment