1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| public String getCookie(String siteName, String cookieName) { String cookieValue = null;
CookieManager cookieManager = CookieManager.getInstance(); String cookies = cookieManager.getCookie(siteName); if (cookies != null) { String[] temp = cookies.split(";"); for (String ar1 : temp) { if (ar1.contains(cookieName)) { String[] temp1 = ar1.split("="); cookieValue = temp1[1]; } } } return cookieValue; }
File file = new File(filePath); RequestBody requestBody = new MultipartBody.Builder() .setType(MultipartBody.FORM) .addFormDataPart("file", file.getName(), RequestBody.create(MediaType.parse("image/*"), file)) .build();
Request request = new Request.Builder() .url(callBack.getUrl()) .post(requestBody) .addHeader("Accept", "*/*") .addHeader("cookie", "ci_session=" + getCookie(APP_URL, "ci_session")) .build(); client.newCall(request).enqueue(callBack);
|