我需要帮助才能在服务器上上传图像。以下代码在moto g5 plus以外的所有设备上均能正常工作。 编译版本22 buildToolsVersion '22 .0.1'
public void uploadFile() {
HttpParams httpParameters = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParameters, TIME_OUT_CONNECTION);
HttpConnectionParams.setSoTimeout(httpParameters, TIME_OUT_SOCKET);
DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters);
httpClient.setParams(httpParameters);
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("FirstName", userInfo.getFirst_name()));
String paramsString = URLEncodedUtils.format(nameValuePairs, "UTF-8");
HttpPost httpPost = new HttpPost(REGISTERATION_API + "?" + paramsString);
InputStreamEntity reqEntity = new InputStreamEntity(new FileInputStream(new File("file path")), -1);
reqEntity.setContentType("binary/octet-stream");
reqEntity.setChunked(true); // Send in multiple parts if needed
httpPost.setEntity(reqEntity);
HttpResponse response = httpClient.execute(httpPost);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
status = line;
}
} catch (Exception e) {
status = e.getMessage();
}
}
答案 0 :(得分:0)
尝试在Moto G5 Plus上使用相机时收到多个错误。询问“请重新启动相机”的地方。经过几次尝试 相机确实可以工作,但是非常令人沮丧。
尝试了“设置”>“应用程序”>“相机”>“存储”>“清除数据”,但这不能总是解决问题。
如果确实可以解决问题,则为暂时问题。