人脸识别传图片总是报错
Ta的回复 :采用此方法转换base64,转换后的信息不可换行,否则报错 public static String getImageBase64(String imgPath) { InputStream in = null; byte[] data = null; try { in = new FileInputStream(imgPath); data = new byte[in.available()]; in.read(data); String imgStr = Base64Util.encode(data); String params = URLEncoder.encode("image", "UTF-8") + "=" + URLEncoder.encode(imgStr, "UTF-8"); in.close(); return params; } catch (IOException e) { e.printStackTrace(); } return ""; }