interface ApiManager
@Multipart
@POST("/member/upload/avatar")
Call<String> uploadFile5(@Part("token")String token,@PartMap Map<String,RequestBody> photo);
public void upload6() {
File file = new File("/storage/emulated/0/image.jpg");
Map<String, RequestBody> map = new HashMap<>();
//head_image为服务器需要的字段,
map.put("head_image" + "\"; filename=\"" + "image.jpg", RequestBody.create(MediaType.parse("image/jpg"), file));
Call<String> call = apiManager.uploadFile5("useId", map);
call.enqueue(new Callback<String>() {
@Override
public void onResponse(Call<String> call, Response<String> response) {
Log.v("Upload", response.message());
}
@Override
public void onFailure(Call<String> call, Throwable t) {
Log.v("onFailure", t.toString());//java.net.SocketException: sendto failed: ECONNRESET (Connection reset by peer) ------此处报异常
}
});
}