OkHttpClient mOkHttpClient = new OkHttpClient();
RequestBody requestBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("title", "wangshu")
.addFormDataPart("image", "wangshu.jpg",
RequestBody.create(MEDIA_TYPE_PNG, new File("")))
.build();
Request request = new Request.Builder()
.header("Authorization", "Client-ID " + "...")
.url("http://wuliu.zhekd.com/index.php/Android/Me/upload")
.post(requestBody)
.build();
mOkHttpClient.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(okhttp3.Call call, IOException e) {
Log.e("wangshu", "shibai");
}
@Override
public void onResponse(okhttp3.Call call, Response response) throws IOException {
Log.e("wangshul", response.body().string());
Log.e("wangshu", "chengg");
}
});
RequestBody.create(MEDIA_TYPE_PNG, new File(""))) File 括号里要的是一个 文件路径 但 图片剪切后是个bitmap 怎么把bitmap转为 file路径尼