在单个POST数组中使用Django Rest Framework上传多个图像? [英] Uploading multiples image with Django Rest Framework in a single POST array?

查看:272
本文介绍了在单个POST数组中使用Django Rest Framework上传多个图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每个人都好,我有一个问题,使用DRF在一个单一的Post数组中获得多个图像。

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.

另一个是最常见的DRF使用,请求方法来解析内容类型中的标题。 http://www.django- rest-framework.org/api-guide/parsers/#how-the-parser-is-determined
但是,如果我是正确的,这使用multipart / form-data方式来做到这一点。

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.

我想要的是一个真正的方法,只是在Json Array中接收数据,这是通过在appcelerator中使用移动应用程序构建的,用户发送一系列图像。

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.

如果有人回答我,如果至少有可能,我会很高兴,因为我发现的所有信息只指向multipart / form-数据。

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']

ukeys = request.FILES['fotos']

感谢您的时间。

推荐答案


我想要的是一个真正的方法,只需要在Json Array中接收数据,这是通过在appcelerator中使用移动应用程序构建,其中用户发送一组图像。

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.

您将需要检查底层请求,并确定完全实际上被送到电线上。 JSON不支持文件原语,因此数组图像可能实际上是一系列具有某种编码的字符串。

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']

request.FILES['fotos']

对于多个值,请使用 request.FILES.getlist ('fotos')

这篇关于在单个POST数组中使用Django Rest Framework上传多个图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆