使用okhttp上传文件
MediaType mediaType = MediaType.parse("multipart/form-data; charset=utf-8");
OkHttpClient okHttpClient = new OkHttpClient();
File file = new File("f://Doc/啦.txt");
Request request = new Request.Builder()
.url("http://localhost:11024/fserver/file?path=/")
.post(RequestBody.create(mediaType, file))
.build();
okHttpClient.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
e.getMessage();
}
~~~~~~
后台执行到 getFile()方法就报错
Caused by: java.io.IOException: Separation boundary was not specified
项目:JFinal