接口在postman是可以正常运行的,file打印也是正常的
请求就是失败
您的每一个用心回答,都会让这个世界变得更美好一些!
兄弟 你传的是.jpg 格式是 image/jpeg 要根据后缀去判断的 public String[] endType = {"jpg" ,"jpeg" , "png" , "gif"}; /** * 上传文件 * @param file */ public void updataFile(File file ){ String type = ""; String path = file.getPath(); if(path.endsWith(endType[2])){ type =endType[2]; }else if(path.endsWith(endType[3])){ type =endType[3]; }else { // 上传类型必须为jpeg type = endType[1]; } // 文件类型 image/jpeg RequestBody requestFile = RequestBody.create(MediaType.parse("image/"+type),file); // 多媒体 body MultipartBody.Part body = MultipartBody.Part.createFormData("image", file.getName(), requestFile);
这是我的部分代码 可以判断 完再根据类型去上传 暂时看出是这个问题 修改看看
请求都没走通,你的异常堆栈不打的?把异常堆栈打出来看看为什么
我这个是file only read
在manifest文件里添加
android:requestLegacyExternalStorage="true"
这是我的部分代码 可以判断 完再根据类型去上传 暂时看出是这个问题 修改看看
请求都没走通,你的异常堆栈不打的?把异常堆栈打出来看看为什么
我这个是file only read
在manifest文件里添加