-1

I've just started messing around with Django REST today and wanted to create a PUT endpoint for a photo upload. The image is then to be saved to a local folder. I'm using the MultiPartParser but request.data and request.FILES are both empty? Anyone know how why that might be?

Views.py:

class ImageUploadView(APIView):
    queryset = Image.objects.all()
    parser_classes = (MultiPartParser,)

    def put(self, request, filename, format=None):
        print(request.FILES)
        return Response(status=204)

models.py

class Image(models.Model):
    file = models.ImageField(upload_to=user_directory_path)
    date_added = models.DateTimeField(auto_now_add=True)

Here is my postman test enter image description here

Owen Chak
  • 51
  • 7
  • try to put some value in POSTMAN while making PUT request – JPG Dec 24 '18 at 06:22
  • https://stackoverflow.com/questions/45564130/django-rest-framework-image-upload – kd007 Dec 24 '18 at 06:35
  • Possible duplicate of [Django REST Framework image upload](https://stackoverflow.com/questions/45564130/django-rest-framework-image-upload) – shafik Dec 24 '18 at 06:40

1 Answers1

2

Adding a key to the file value in the postman form fixed it enter image description here

Owen Chak
  • 51
  • 7