我使用翻新将图像上传到服务器,但是有一个奇怪的问题

api方法声明:

@POST("/uploadImage")
@Multipart
Result<UploadImageResponse> uploadImage(@Part("image") TypedByteArray image);

其余适配器用户自定义客户端:
OkClient client = new OkClient(getUnsafeOkHttpClient());

在哪里
private OkHttpClient getUnsafeOkHttpClient() {

    try {
        // Create a trust manager that does not validate certificate chains
        final TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
            @Override
            public void checkClientTrusted(
                    java.security.cert.X509Certificate[] chain,
                    String authType) throws CertificateException {
            }

            @Override
            public void checkServerTrusted(
                    java.security.cert.X509Certificate[] chain,
                    String authType) throws CertificateException {
            }

            @Override
            public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                return null;
            }
        }};

        // Install the all-trusting trust manager
        final SSLContext sslContext = SSLContext.getInstance("SSL");
        sslContext.init(null, trustAllCerts,
                new java.security.SecureRandom());
        // Create an ssl socket factory with our all-trusting manager
        final SSLSocketFactory sslSocketFactory = sslContext
                .getSocketFactory();

        OkHttpClient okHttpClient = new OkHttpClient();
        okHttpClient.setSslSocketFactory(sslSocketFactory);
        okHttpClient.setHostnameVerifier(new HostnameVerifier() {

            @Override
            public boolean verify(String hostname, SSLSession session) {
                return true;
            }
        });

        return okHttpClient;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

异常日志:
D/Retrofit: javax.net.ssl.SSLException: Write error: ssl=0x7f70604080: I/O error during system call, Broken pipe
                                                                   at com.android.org.conscrypt.NativeCrypto.SSL_write(Native Method)
                                                                   at com.android.org.conscrypt.OpenSSLSocketImpl$SSLOutputStream.write(OpenSSLSocketImpl.java:771)
                                                                   at okio.Okio$1.write(Okio.java:80)
                                                                   at okio.AsyncTimeout$1.write(AsyncTimeout.java:155)
                                                                   at okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:176)
                                                                   at okio.RealBufferedSink.write(RealBufferedSink.java:46)
                                                                   at com.squareup.okhttp.internal.http.Http1xStream$FixedLengthSink.write(Http1xStream.java:288)
                                                                   at okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:176)
                                                                   at okio.RealBufferedSink$1.write(RealBufferedSink.java:198)
                                                                   at java.io.OutputStream.write(OutputStream.java:82)
                                                                   at retrofit.mime.TypedByteArray.writeTo(TypedByteArray.java:66)
                                                                   at retrofit.client.UrlConnectionClient.prepareRequest(UrlConnectionClient.java:68)
                                                                   at retrofit.client.UrlConnectionClient.execute(UrlConnectionClient.java:37)
                                                                   at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:321)
                                                                   at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:240)
                                                                   at java.lang.reflect.Proxy.invoke(Proxy.java:393)
                                                                   at $Proxy3.uploadImage(Unknown Source)

最佳答案

此异常是服务器端文件限制的结果

10-08 18:26