Selaa lähdekoodia

人脸对比照片本地保存

tongfeng 3 vuotta sitten
vanhempi
commit
614fbf2851

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

@@ -48,7 +48,7 @@ public class SpFileUploadController {
 
 	/**
 	 * 文件上传
-	 * 
+	 *
 	 * @param spUploadVO
 	 * @return
 	 */
@@ -112,7 +112,7 @@ public class SpFileUploadController {
 		JSONObject json = JSONObject.parseObject(image);
 		String imagePath="";
 		try {
-			imagePath = FileUploadUtils.saveImage(json.getString("base64"));
+			imagePath = FileUploadUtils.saveFaceImage(json.getString("base64"));
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
@@ -124,47 +124,4 @@ public class SpFileUploadController {
 		return map;
 	}
 
-	@RequestMapping("/getPreview")
-	public Map<String,Object> getPreview(@RequestBody String fileKey){
-		JSONObject json = JSONObject.parseObject(fileKey);
-		String imagePath="";
-		try {
-			imagePath = FileUploadUtils.getPreviewUrl(json.getString("fileKey"));
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		// SUCCESS(100,"操作成功!"),
-		Map<String, Object> map = new HashMap<>();
-		map.put("code", 100);
-		map.put("msg", "操作成功!");
-		map.put("url",imagePath);
-		return map;
-	}
-
-	@RequestMapping("/getFile")
-	public Map<String,Object> getFile(@RequestBody String fileKey){
-		JSONObject json = JSONObject.parseObject(fileKey);
-		File file = null;
-		try {
-			file = FileUploadUtils.getFileWithPath(json.getString("fileKey"));
-		} catch (Exception e) {
-			throw new RuntimeException(e);
-		}
-		ObjectMapper mapper = new ObjectMapper();
-		String s = null;
-		try {
-			s = mapper.writeValueAsString(file);
-		} catch (JsonProcessingException e) {
-			throw new RuntimeException(e);
-		}
-		Map<String, Object> map = new HashMap<>();
-		map.put("code", 100);
-		map.put("msg", "操作成功!");
-		map.put("file",s);
-		return map;
-	}
-
-
-
-
 }

+ 0 - 26
java/sp-version/src/main/java/com/anji/sp/util/file/FileUploadUtils.java

@@ -220,7 +220,6 @@ public class FileUploadUtils {
 	}
 
 	public static String uuid() {
-
 		return UUID.randomUUID().toString().replace("-", "");
 	}
 
@@ -366,15 +365,6 @@ public class FileUploadUtils {
 		}
 	}
 
-	public static String getPreviewUrl(String fileKey) {
-		try {
-			return fileHandle.getPreviewUrl(fileKey);
-		} catch (Exception e) {
-			log.error("图片预览失败:" + e.getLocalizedMessage());
-			return null;
-		}
-	}
-
 	/**
 	 * 上传文件通过文件的流
 	 * 
@@ -404,22 +394,6 @@ public class FileUploadUtils {
 		}
 	}
 
-
-	public static File getFileWithPath(String filePath) throws Exception {
-		InputStream inputStream = fileHandle.getObject(filePath);
-		File file = File.createTempFile("compare",".jpeg");
-		file.deleteOnExit();
-		OutputStream outputStream = new FileOutputStream(file);
-		int bytesRead = 0;
-		byte[] buffer = new byte[8192];
-		while ((bytesRead = inputStream.read(buffer, 0, 8192)) != -1) {
-			outputStream.write(buffer, 0, bytesRead);
-		}
-		inputStream.close();
-		outputStream.close();
-		return file;
-	}
-
 	/**
 	 * 判断操作系统是否为Windows
 	 *