您好,登錄后才能下訂單哦!
/** by keinta in China sz email: hrony@qq.com 2016.10.18
CN: 此JAR包里面已經集成了android http 網絡請求包,也封裝了 MultipartEntityBuilder 文件與文字同時上傳,實現向下兼容
你只需要添加這兩個包就可以實現android 的多類型網絡傳輸了
Please add the packages :
compile files('libs/org.apache.http.legacy.jar')
compile files('libs/httpmime-4.3.5.jar')
compile files('libs/android_httpcore_4.3.2.jar')// https://pan.baidu.com/s/1i5mEO53
Inside the JAR package has integrated the android HTTP request packet network, also encapsulates the upload MultipartEntityBuilder file with the text at the same time, achieve backward compatibility
/** example
* @param context
* @param url
* @param filekey
* @param params
* @param file
* @return
*/
public String postMutil(Context context, String url, String filekey, final TreeMap<String, String> params, File file) {
// ***省略***
//Image attaching
MultipartEntityBuilder multipartEntity = MultipartEntityBuilder.create();
if (file != null && file.exists()) {
multipartEntity.addBinaryBody(filekey, file, ContentType.MULTIPART_FORM_DATA, file.getName());
}
//Json string attaching
for (Map.Entry<String, String> entry : params.entrySet()) {
multipartEntity.addPart(entry.getKey(), new StringBody(entry.getValue()));
}
httppost.setEntity(multipartEntity.build());
// ******省略******
}
compile files('libs/android_httpcore_4.3.2.jar')// https://pan.baidu.com/s/1i5mEO53 包已經上傳到百度云可以直接下載用
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。