Answers for "django rest api using files"

0

django rest api using files

from rest_framework import status
from rest_framework.response import Response
from rest_framework.views import APIView
from rest_framework.parsers import FileUploadParser

# views.py
class FileUploadView(APIView):
    parser_classes = [FileUploadParser]

    def put(self, request, filename, format=None):
        file_obj = request.data['file']
        # ...
        # do some stuff with uploaded file
        # ...
        return Response(status=204)
Posted by: Guest on December-03-2020

Python Answers by Framework

Browse Popular Code Answers by Language