wangwei 7 лет назад
Родитель
Сommit
8508438b0c

+ 4 - 2
examcloud-exchange-outer-api-provider/src/main/java/cn/com/qmth/examcloud/exchange/outer/api/provider/FaceppController.java

@@ -7,6 +7,7 @@ import java.util.Map;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 
 
 import org.apache.commons.fileupload.disk.DiskFileItem;
 import org.apache.commons.fileupload.disk.DiskFileItem;
+import org.apache.tomcat.util.http.fileupload.FileUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -94,7 +95,7 @@ public class FaceppController extends ControllerSupport {
 
 
 		List<Map<String, String>> ret = Lists.newArrayList();
 		List<Map<String, String>> ret = Lists.newArrayList();
 
 
-		String tempDirPath = storeLocation.getCanonicalPath() + File.separator
+		String tempDirPath = storeLocation.getParent() + File.separator
 				+ System.currentTimeMillis();
 				+ System.currentTimeMillis();
 		File tempDir = new File(tempDirPath);
 		File tempDir = new File(tempDirPath);
 		try {
 		try {
@@ -113,6 +114,7 @@ public class FaceppController extends ControllerSupport {
 			Map<String, String> map = Maps.newHashMap();
 			Map<String, String> map = Maps.newHashMap();
 
 
 			if (f.length() > MAX_SIZE * 1024) {
 			if (f.length() > MAX_SIZE * 1024) {
+				map.put("file", f.getName());
 				map.put("statusCode", "EX-620005");
 				map.put("statusCode", "EX-620005");
 				map.put("statusDesc", "文件大小超过500KB");
 				map.put("statusDesc", "文件大小超过500KB");
 				ret.add(map);
 				ret.add(map);
@@ -133,7 +135,7 @@ public class FaceppController extends ControllerSupport {
 			ret.add(map);
 			ret.add(map);
 		}
 		}
 
 
-		tempDir.delete();
+		FileUtils.deleteDirectory(tempDir);
 
 
 		return ret;
 		return ret;
 	}
 	}

+ 2 - 2
examcloud-exchange-outer-service/src/main/java/cn/com/qmth/examcloud/exchange/outer/service/FaceppService.java

@@ -78,7 +78,7 @@ public class FaceppService {
 		String faceToken = null;
 		String faceToken = null;
 		while (true) {
 		while (true) {
 			if (time < 1) {
 			if (time < 1) {
-				throw new StatusException("EX--111010", "人脸检测失败");
+				throw new StatusException("EX-111010", "人脸检测失败");
 			}
 			}
 
 
 			CloseableHttpClient httpClient = HttpClients.createDefault();
 			CloseableHttpClient httpClient = HttpClients.createDefault();
@@ -181,7 +181,7 @@ public class FaceppService {
 		Long rootOrgId = accessUser.getRootOrgId();
 		Long rootOrgId = accessUser.getRootOrgId();
 		String userToken = accessUser.getUserToken();
 		String userToken = accessUser.getUserToken();
 		if (!(fileName.endsWith(".jpg") || fileName.endsWith(".png"))) {
 		if (!(fileName.endsWith(".jpg") || fileName.endsWith(".png"))) {
-			throw new StatusException("B-101001", "文件格式错误");
+			throw new StatusException("EX-101001", "文件格式错误");
 		}
 		}
 
 
 		String identityNumber = fileName.substring(0, fileName.lastIndexOf("."));
 		String identityNumber = fileName.substring(0, fileName.lastIndexOf("."));