3

Good day everyone, I have a problem using DRF for getting multiples images in a single Post with an array.

I have read a lot about this topic, the most common solution is to encode64 the string, but is not an approach that I want because take a lot of resource that we don't have.

The other one, is the most common that DRF use, to request method to Parse the header in the content type. http://www.django-rest-framework.org/api-guide/parsers/#how-the-parser-is-determined But if I'm correct, this use a multipart/form-data way to do it.

The really one that I want, is a way to do it just receiving the data in a Json Array, this is by using a mobile app build in appcelerator where the user sends an array of images.

I would be glad if someone answer me if at least is possible, because all the information that I have found only point to multipart/form-data.

By the way, is possible to upload a single file, but not multiples, I have done it with this:

ukeys = request.FILES['fotos']

Thanks for your time.

1 Answer 1

6

The really one that I want, is a way to do it just receiving the data in a Json Array, this is by using a mobile app build in appcelerator where the user sends an array of images.

You'll want to inspect the underlying request and figure out exactly what's actually being sent on the wire. JSON doesn't support a file primitive, so the "array of images" is likely to actually be an array of strings with some kind of encoding.

request.FILES['fotos']

For multiple values, use request.FILES.getlist('fotos').

Sign up to request clarification or add additional context in comments.

1 Comment

When I receive a single file it returns the name of the file encode in unicode: u' foto1.jpg But when I use getlist it only returns me an empty array. [] Update: I tried to print ukeys that is the variable of the ukeys = request.FILES.getlist('fotos'), and only give me an empty array, but if a print the request.Files, it give me the values encode in unicode, and I can even use a For to get the image name. Now the only problem that I have is how the application sends me the "array of images"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.