API v3 图片上传400,文件二进制内容不是图片问题,找不到问题了

小游戏 企业微信 微信支付 小程序 文章 2020-07-30 21:16 787 0 全屏看文

AI助手支持GPT4.0

API v3 图片上传400,文件二进制内容不是图片问题,找不到问题了

在使用v3接口上传图片时,总是报文件二进制内容不是图片。图片的二进制是直接读取出来的没有经过任何处理。找了很久不知道是哪里出了问题。还希望能帮忙看看。😭

这个是读取图片二进制的代码

这个是请求拼接的body

When using V3 interface to upload pictures, it is always reported that the binary content of the file is not a picture. The binary image is directly read out without any processing. Looking for a long time, I don't know where the problem is. I hope I can help. 😭 This is the code to read the binary image, and this is the body requesting splicing

回答:

北望沣渭:

问题出在 body += ‘%srn’ file_byte 你这里是当成字符串输出了,需要查下python,怎么输出二进制

ん:还想再请教一下,这个post请求的body不是字符串吗?
北望沣渭:form-data 允许上传二进制,载荷 bundary 中的file即是二进制,这个接口上传的即是混合meta字符串+file二进制格式。
ん:好的,谢谢您!!

-EOF-

AI助手支持GPT4.0