Ver Fonte

人脸对比照片本地保存

tongfeng há 2 anos atrás
pai
commit
fa07c082e1

+ 1 - 1
java/sp-version/src/main/java/com/anji/sp/controller/SpFileUploadController.java

@@ -112,7 +112,7 @@ public class SpFileUploadController {
 		JSONObject json = JSONObject.parseObject(image);
 		String imagePath="";
 		try {
-			imagePath = FileUploadUtils.saveFaceImage(json.getString("base64"));
+			imagePath = FileUploadUtils.saveFaceImage(json.getString("base64"),json.getString("filePath"));
 		} catch (Exception e) {
 			e.printStackTrace();
 		}

+ 4 - 5
java/sp-version/src/main/java/com/anji/sp/util/file/FileUploadUtils.java

@@ -324,7 +324,7 @@ public class FileUploadUtils {
 	 * @param image 图片数据
 	 * @return
 	 */
-	public static String saveFaceImage(String imgStr) {
+	public static String saveFaceImage(String imgStr,String filePath) {
 
 		if (imgStr == null) // 图像数据为空
 			return null;
@@ -352,13 +352,12 @@ public class FileUploadUtils {
 			String uuid = uuid();
 			// 拼接文件路径
 			String fileName = uuid + "." + suffix;
-			// 图片的路径
-			String imagePath = "facecompare" + "/" + fileName;
 			// 这里目前只会说图片的
 			String contentType = "image/" + suffix;
-			uploadFile(imagePath, contentType, b);
+			uploadFile(filePath, contentType, b);
 			// FileUtils.writeByteArrayToFile(fullPath, b);
-			return imagePath;
+			log.info("上传图片成功"+filePath);
+			return filePath;
 		} catch (Exception e) {
 			log.error("上传图片失败:" + e.getLocalizedMessage());
 			return null;