class FileUploadView(APIView):
parser_classes = (FileUploadParser, )
def post(self, request, format='ваш формат'):
file = request.FILES['file']
_ = open('/path/' + up_file.name, 'wb+')
for chunk in up_file.chunks():
_.write(chunk)
_.close()
# или
class ExampleViewSet(ModelViewSet):
queryset = Example.objects.all()
serializer_class = ExampleSerializer
def pre_save(self, obj):
obj.file = self.request.FILES.get('file')