M
M
marselabdullin2020-07-30 19:51:51
Django
marselabdullin, 2020-07-30 19:51:51

TypeError at /image/ post() missing 1 required positional argument: 'filename' in django rest?

I send an image via api and receive it using this view:

class ImageProfile(APIView):
    parser_classes = [FileUploadParser]

    def post(self, request, filename, format=None):
        image = request.data['file']
        ImageProfile.objects.create(image=image)
        return Response(status=200)

But it does not find filename even though it is passed as a parameter in the http response:

POST /image/ HTTP/1.1
Host: 127.0.0.1:8000
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
cache-control: no-cache
Postman-Token: fcf56493-cdf1-4a23-a863-03dacb5a59ad

Content-Disposition: form-data; name="file"; filename="C:\Users\Marsel\Pictures\1_grunt.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dr. Bacon, 2020-07-30
@bacon

Where does post suddenly have a filename argument?

I
IceJOKER, 2015-02-11
@IceJOKER

Imagine that there are 10 entries in the array - what will happen when the (pre)last iteration is performed?

$rows[$i+1]
$rows[$i+2]

B
Boris Benkovsky, 2015-02-11
@benbor

A club of wangers gathered sharply here, and we will guess what error it writes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question