上传照片 出现expected 705 bytes but received 8192

qq_31952923 2016-10-20 12:33:05
我做的功能是一个发帖,在打开相机拍照上传的时候出现这个expected 705 bytes but received 8192,上传本地相册的图片没有问题,补充,通过测试 用红米1s ,Nexus 5是可行的,但是用小米5s测试却不行,但是有时候也能上传成功,绝大部分是弹出toast “expected 705 bytes but received 8192”
上传刚拍的图片log

上传本地的图片log


private void UpLoadPhotoOfCamara(String token,String secret,String path){
isCamera = true;
if(!svProgressHUD.isShowing()){
svProgressHUD.showWithStatus(this,getResources().getString(R.string.loadding));
}
GetParamsUtill getParamsUtill = new GetParamsUtill();
getParamsUtill.add("token", token);
getParamsUtill.add("secret", secret);
Map<String, Object> map = new HashMap<>();
map.put("uploadFile", new File(path));
netWorkUtill.uploadTx(getParamsUtill, this, map, NetWorkUtill.GET_REQ_UPLOAD_ACTION);
}

public void uploadTx(GetParamsUtill params, final MyReceiveDataListener receiveDataListener,Map<String,Object> map,final int action) {

postUpload(params, new Callback.CommonCallback<String>() {
@Override
public void onSuccess(String result) {
// Toast.makeText(x.app(), result, Toast.LENGTH_LONG).show();
// receiveDataListener.onReceive();
Log.i("上传",result);
// System.out.println("上传"+result);
String errCode = "";
String errMsg = "";
String responseData = "";
try {
JSONObject jsonObject = new JSONObject(result);
errCode = jsonObject.optString("errcode");
errMsg = jsonObject.optString("errmsg");
if ("00000000".equals(errCode)) {
responseData = jsonObject.optJSONArray("data").toString();
}
} catch (JSONException e) {
e.printStackTrace();
}
Log.i("NetWorkUtils","接口返回receive");
receiveDataListener.onReceive(action,errCode,errMsg,responseData);
}

@Override
public void onError(Throwable ex, boolean isOnCallback) {
Toast.makeText(x.app(), ex.getMessage(), Toast.LENGTH_LONG).show();
Log.i("NetWorkUtils","接口返回error");
receiveDataListener.onFile(action,ex);
}

@Override
public void onCancelled(CancelledException cex) {
Toast.makeText(x.app(), "cancelled", Toast.LENGTH_LONG).show();
Log.i("NetWorkUtils","接口返回cancelled");
receiveDataListener.onFile(action,cex);
}

@Override
public void onFinished() {

}
},Constants.UPLOAD_URL,map);

public void postUpload(GetParamsUtill params,
final Callback.CommonCallback<String> requestCallBack,String url,Map<String,Object> map) {


// Log.i("RequestParams",params.getStringParams().size()+"");
RequestParams requestParams = params.getParams(url);
requestParams.setMultipart(true);

for (Map.Entry<String,Object> entry : map.entrySet()) {
requestParams.addBodyParameter(entry.getKey(),entry.getValue(),null);//new File(entry.getValue())
System.out.println("BaseNetworkUtill,"+entry.getKey()+","+entry.getValue());


}
if (!url.equals(Constants.WEATHER_URL)) {
requestParams.addBodyParameter("authcode", addAuth(url));
}

x.http().post(requestParams,requestCallBack);

}
求大神帮忙解答!多谢了
...全文
1406 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
2021新牧码人 2018-01-02
  • 打赏
  • 举报
回复
我也遇到了类似的问题,有时候能传成功,有时候不行, 先是用一个线程保存文件 紧接着就就上传该文件,就出现了概率性的报上面的错误 总之就是确保你上传的文件是已经写好的,应该上传是不会出错的(我将自己的线程去掉果然就OK啦)
qq_31952923 2016-10-20
  • 打赏
  • 举报
回复
引用 1 楼 qq_33667176 的回复:
图片太大了,压缩一下
压缩后可以上传了
qq_31952923 2016-10-20
  • 打赏
  • 举报
回复
引用 3 楼 mills_ 的回复:
能上传本地照片说明上传模块没问题,你看下是不是拍照时生成的图片名称太长了
图片名字也不长 我上面有截图,你可以看看。
mills_ 2016-10-20
  • 打赏
  • 举报
回复
能上传本地照片说明上传模块没问题,你看下是不是拍照时生成的图片名称太长了
qq_31952923 2016-10-20
  • 打赏
  • 举报
回复
引用 1 楼 qq_33667176 的回复:
图片太大了,压缩一下
那为何有的手机可以呢?
德超 2016-10-20
  • 打赏
  • 举报
回复
图片太大了,压缩一下
笔记本的风扇控制 ---------------------------------------- 09 November 2006. Summary of changes for version 20061109: 1) ACPI CA Core Subsystem: Optimized the Load ASL operator in the case where the source operand is an operation region. Simply map the operation region memory, instead of performing a bytewise read. (Region must be of type SystemMemory, see below.) Fixed the Load ASL operator for the case where the source operand is a region field. A buffer object is also allowed as the source operand. BZ 480 Fixed a problem where the Load ASL operator allowed the source operand to be an operation region of any type. It is now restricted to regions of type SystemMemory, as per the ACPI specification. BZ 481 Additional cleanup and optimizations for the new Table Manager code. AcpiEnable will now fail if all of the required ACPI tables are not loaded (FADT, FACS, DSDT). BZ 477 Added #pragma pack(8/4) to acobject.h to ensure that the structures in this header are always compiled as aligned. The ACPI_OPERAND_OBJECT has been manually optimized to be aligned and will not work if it is byte-packed. Example Code and Data Size: These are the sizes for the OS- independent acpica.lib produced by the Microsoft Visual C++ 6.0 32- bit compiler. The debug version of the code includes the debug output trace mechanism and has a much larger code and data size. Previous Release: Non-Debug Version: 78.1K Code, 17.1K Data, 95.2K Total Debug Version: 155.4K Code, 63.1K Data, 218.5K Total Current Release: Non-Debug Version: 77.9K Code, 17.0K Data, 94.9K Total Debug Version: 155.2K Code, 63.1K Data, 218.3K Total 2) iASL Compiler/Disassembler and Tools: Fixed a problem where the presence of the _OSI predefined control method within complex expressions could cause an internal compiler error. AcpiExec: Implemented full region support for multiple address spaces. SpaceId is now part of the REGION object. BZ 429 ---------------------------------------- 11 Oc

80,349

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧