Reputation: 35
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.
Upvotes: 3
Views: 3058
Reputation: 33901
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')
.
Upvotes: 6