|
@@ -73,20 +73,20 @@ public class FaceOuterServiceProvider extends ControllerSupport implements FaceO
|
|
}
|
|
}
|
|
|
|
|
|
if (photoUrl.startsWith("http")) {
|
|
if (photoUrl.startsWith("http")) {
|
|
- byte[] bs = HttpClientUtil.get(photoUrl);
|
|
|
|
-
|
|
|
|
int lastIndexOf = photoUrl.lastIndexOf(".");
|
|
int lastIndexOf = photoUrl.lastIndexOf(".");
|
|
if (0 > lastIndexOf) {
|
|
if (0 > lastIndexOf) {
|
|
- throw new StatusException("100002",
|
|
|
|
- "photoPath is not end with photo file suffix.");
|
|
|
|
|
|
+ throw new StatusException("100002", "photoPath is not end with photo file suffix.");
|
|
}
|
|
}
|
|
- String fileSuffix = photoUrl.substring(lastIndexOf);
|
|
|
|
|
|
|
|
|
|
+ String fileSuffix = photoUrl.substring(lastIndexOf);
|
|
String fileName = System.currentTimeMillis() + fileSuffix;
|
|
String fileName = System.currentTimeMillis() + fileSuffix;
|
|
File temp = new File(systemConfig.getTempDataDir() + File.separator + "student_photo"
|
|
File temp = new File(systemConfig.getTempDataDir() + File.separator + "student_photo"
|
|
+ File.separator + fileName);
|
|
+ File.separator + fileName);
|
|
|
|
|
|
try {
|
|
try {
|
|
|
|
+ // 文件大小限制
|
|
|
|
+ byte[] bs = HttpClientUtil.get(photoUrl, MAX_SIZE * 1024);
|
|
|
|
+
|
|
FileUtils.writeByteArrayToFile(temp, bs);
|
|
FileUtils.writeByteArrayToFile(temp, bs);
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
throw new StatusException("100003", "文件读写失败");
|
|
throw new StatusException("100003", "文件读写失败");
|
|
@@ -121,6 +121,12 @@ public class FaceOuterServiceProvider extends ControllerSupport implements FaceO
|
|
if (!fileName.matches("[^\\.\\s]+\\.[^\\.\\s]+")) {
|
|
if (!fileName.matches("[^\\.\\s]+\\.[^\\.\\s]+")) {
|
|
throw new StatusException("600101", "文件名不合法");
|
|
throw new StatusException("600101", "文件名不合法");
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // 文件大小限制
|
|
|
|
+ if (file.getSize() > MAX_SIZE * 1024) {
|
|
|
|
+ throw new StatusException("620005", "图片大小超过500KB");
|
|
|
|
+ }
|
|
|
|
+
|
|
String fileSuffix = fileName.substring(fileName.lastIndexOf("."));
|
|
String fileSuffix = fileName.substring(fileName.lastIndexOf("."));
|
|
|
|
|
|
faceService.processFace(rootOrgId, identityNumber, fileSuffix, storeLocation, operator);
|
|
faceService.processFace(rootOrgId, identityNumber, fileSuffix, storeLocation, operator);
|
|
@@ -145,6 +151,7 @@ public class FaceOuterServiceProvider extends ControllerSupport implements FaceO
|
|
if (!filename.endsWith(".zip")) {
|
|
if (!filename.endsWith(".zip")) {
|
|
throw new StatusException("620001", "文件格式不正确,必须是zip格式的压缩包");
|
|
throw new StatusException("620001", "文件格式不正确,必须是zip格式的压缩包");
|
|
}
|
|
}
|
|
|
|
+
|
|
// 文件大小限制
|
|
// 文件大小限制
|
|
if (file.getSize() > ZIP_MAX_SIZE * 1024 * 1024) {
|
|
if (file.getSize() > ZIP_MAX_SIZE * 1024 * 1024) {
|
|
throw new StatusException("620002", "文件大小超过50M,请分批导入");
|
|
throw new StatusException("620002", "文件大小超过50M,请分批导入");
|
|
@@ -178,6 +185,7 @@ public class FaceOuterServiceProvider extends ControllerSupport implements FaceO
|
|
ret.add(map);
|
|
ret.add(map);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
+
|
|
try {
|
|
try {
|
|
if (StringUtils.containsWhitespace(fileName)) {
|
|
if (StringUtils.containsWhitespace(fileName)) {
|
|
throw new StatusException("600100", "文件名不能含有空白字符");
|
|
throw new StatusException("600100", "文件名不能含有空白字符");
|