List of usage examples for com.squareup.okhttp MultipartBuilder addPart
public MultipartBuilder addPart(RequestBody body)
From source file:com.wialon.remote.OkSdkHttpClient.java
License:Apache License
@Override public void postFile(String url, Map<String, String> params, Callback callback, int timeout, File file) { //Method will work at 2.1 version of library https://github.com/square/okhttp/issues/963 and https://github.com/square/okhttp/pull/969 MultipartBuilder builder = new MultipartBuilder(); builder.type(MultipartBuilder.FORM); RequestBody paramsBody = paramsMapToRequestBody(params); if (paramsBody != null) { builder.addPart(paramsBody); }// www. j a v a2 s. c o m builder.addPart(RequestBody.create(MediaType.parse(""), file)); Request request = new Request.Builder().url(url).post(builder.build()).build(); threadPool.submit(new HttpRequest(getHttpClient(timeout), request, callback)); }