改造中管道破损异常(发送失败:EPIPE(管道破损))

Broken Pipe exception (sendto failed: EPIPE (Broken pipe)) in retrofit

提问人:Manikanta 提问时间:5/30/2015 最后编辑:Shailendra MaddaManikanta 更新时间:7/10/2017 访问量:1706

问:

我正在使用 retrofit 在 android 中上传文件,我正在使用以下服务接口

public interface FileUploadService {


    public static final String BASE_URL = "server url";

    @Multipart
    @POST("/upload")
    void upload(@Part("file") TypedFile file,
                @Part("path") String path,
                Callback<Pk_Response> cb);
}

这是我的服务生成器类

public class ServiceGenerator {

    // No need to instantiate this class.
    private ServiceGenerator() {
    }


    public static <S> S createService(Class<S> serviceClass, String baseUrl) {

        RestAdapter.Builder builder = new RestAdapter.Builder()
                .setEndpoint(baseUrl)
                .setRequestInterceptor(new RequestInterceptor() {
                    @Override
                    public void intercept(RequestFacade request) {
                        request.addHeader("accesstoken", "token");                            request.addHeader("Content-Type", "multipart/form-data");
                    }
                })
                .setClient(new OkClient(new OkHttpClient()));

        RestAdapter adapter = builder.build();

        return adapter.create(serviceClass);
    }
}

这就是我在活动中调用服务的方式

FileUploadService service = ServiceGenerator.createService(FileUploadService.class, FileUploadService.BASE_URL);
    TypedFile typedFile = new TypedFile("image/jpeg", new File(outputFileUri.getPath()));
    String path = "directory11";

service.upload(typedFile, path, new Callback<Pk_Response>() {

    @Override
    public void success(Pk_Response pk_response, retrofit.client.Response response) {
        Toast.makeText(getApplicationContext(),"requestsuccess",Toast.LENGTH_LONG).show();
    }

    @Override
    public void failure(RetrofitError error) {
        Log.e("Upload", "error");
        error.toString();
    }
});

我收到以下错误:

java.net.SocketException: sendto failed: EPIPE (Broken pipe)
sendto failed: EPIPE (Broken pipe)

请帮我解决此问题

Android 文件 上传 改造

评论

2赞 Silvia H 8/23/2015
滴滴:你找到解决方案了吗?
0赞 Shailendra Madda 3/5/2016
我也面临同样的问题,你发现了吗??
0赞 Suraj Bahadur 12/18/2019
我面临同样的问题

答: 暂无答案