如何在POSTMAN中使用raw上传图像?

Shi*_*rma 8 django request image-upload postman

我正在尝试使用POSTMAN上传图像.我成功使用了表单数据,但没有使用原始JSON格式传递数据.

通过POSTMAN中的表单数据请求:

在此输入图像描述

请求通过curl:

curl -X POST -H "Content-Type:multipart/form-data" -F "profile_image=@/home/shivani/Pictures/Wallpapers/8018.jpg" http://127.0.0.1:8000/api/users/1/image/
{"message":"Image Uploaded successfully.","profile_image":"http://res.cloudinary.com/aubergine-solutions/image/upload/v1430204993/w0oxhv6beaxd14twrxmi.jpg"}~ 
Run Code Online (Sandbox Code Playgroud)

当我发送原始请求时:

在此输入图像描述

虽然我在Django设置中添加了MultiPartParser,但是出现以下错误:

在此输入图像描述

任何人都可以帮忙解决这个问题吗?

小智 5

当我使用图像上传时,我使用base64对图像进行编码,并将编码后的字符串作为json字符串传递。在后端,我们可以对字符串进行解码并生成图像。