use HttpResponse in /media endpoint
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
41b6bffa61
commit
90d1149c07
3 changed files with 10 additions and 8 deletions
|
|
@ -1,3 +1,4 @@
|
|||
from django.http import HttpResponse
|
||||
from django.urls import path
|
||||
from drf_yasg.utils import swagger_auto_schema
|
||||
from rest_framework import status
|
||||
|
|
@ -13,12 +14,12 @@ from files.models import File
|
|||
def media_urls(request, id, format=None):
|
||||
try:
|
||||
file = File.objects.get(file=id)
|
||||
return Response(status=status.HTTP_200_OK,
|
||||
content_type=file.mime_type,
|
||||
headers={
|
||||
'X-Accel-Redirect': f'/redirect_media/{id}',
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
}) # TODO Expires and Cache-Control
|
||||
return HttpResponse(status=status.HTTP_200_OK,
|
||||
content_type=file.mime_type,
|
||||
headers={
|
||||
'X-Accel-Redirect': f'/redirect_media/{id}',
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
}) # TODO Expires and Cache-Control
|
||||
|
||||
except File.DoesNotExist:
|
||||
return Response(status=status.HTTP_404_NOT_FOUND)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue