Mark一下:
@Overridepublic void uploadSignPdfFile(File file) {RequestBody fileRQ = RequestBody.create(MediaType.parse("multipart/form-data"), file);RequestBody requestBody = new MultipartBody.Builder().setType(MultipartBody.FORM).addFormDataPart("file", file.getName(), fileRQ).build();MultipartBody.Part part = MultipartBody.Part.create(requestBody);String url = mSpfUtils.getServerBaseUrl() + "/servlet/file.FileUpServlet";Request request= new Request.Builder().url(url).post(requestBody).build();new OkHttpClient().newCall(request).enqueue(new Callback() {@Overridepublic void onFailure(@NotNull Call call, @NotNull IOException e) {Log.d("上传图片失败", "onFailure: ");}@Overridepublic void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {try {JSONObject obj = new JSONObject(response.body().string()); // JSONArray data = obj.getJSONArray("data"); // if (data!= null && data.length() > 0) { // long fileid = data.getJSONObject(0).getLong("fileId"); // getView().callWebFileId(fileid); // Looper.loop(); // getView().showToast("上传图片成功"); // }} catch (JSONException e) {e.printStackTrace();}}});}