Retrofit或Volley-发布JSON,其中包含编码为base64字符串的图像

时间:2019-01-15 15:20:22

标签: android-volley retrofit2 okhttp3

我有一台服务器,其api需要json作为输入。 例如

{
    "title":"Body Lotion",
    "Category":"Beauty Product",
    "image1":"base64encodedImageString1",
    "image2":"base64encodedImageString2",
    "image3":"base64encodedImageString3",
    "image4":"base64encodedImageString4"
}

我的挑战是,完整请求通过邮递员成功完成,但是从Retrofit或Volley发送时失败。

如果删除了图像参数或将base64字符串替换为短字符串,则在翻新和截击中相同的请求成功。 请求的长度可能有问题吗? Retrofit,Volley或OkHttp3是否限制json请求的大小?

是否有一个无需更改服务器端的解决方案? 我已经研究过,试图徒劳地对此行为做出准确的解释。请告知。

我得到的错误是;

java.io.IOException: unexpected end of stream on Connection
at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:208)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:88)
...
Caused by: java.io.EOFException: \n not found:

0 个答案:

没有答案
相关问题