3
0

2 کامیت‌ها 8b35a9f51b ... 9edf4bf86d

نویسنده SHA1 پیام تاریخ
  Danj0rr 9edf4bf86d Merge remote-tracking branch 'origin/develop' into develop 11 ماه پیش
  Danj0rr 603e1d1325 修改文件名获取方式 11 ماه پیش
1فایلهای تغییر یافته به همراه14 افزوده شده و 4 حذف شده
  1. 14 4
      src/main/java/com/kexun/controller/FileUploadController.java

+ 14 - 4
src/main/java/com/kexun/controller/FileUploadController.java

@@ -152,9 +152,20 @@ public class FileUploadController {
             , @RequestParam String model_name, @RequestParam String model_type, @RequestParam String model_no, @RequestParam String output_list, SysUser sysUser
     ) throws IOException {
         int type = Integer.parseInt(model_type);
+
+        String filename="";
+        String filefmt="";
+        int lastDotIndex = name.lastIndexOf(".");
+        if (lastDotIndex != -1 && lastDotIndex < name.length() - 1) {
+            filename = name.substring(0, lastDotIndex);
+            filefmt = name.substring(lastDotIndex + 1);
+        } else {
+            return Result.error("文件名中不包含点或点在末尾");
+        }
+
         if (type == 1 || type == 2) {
-            String filename = name.split("\\.")[0];
-            String filefmt = name.split("\\.")[1];
+
+
             String fullFileName = String.join("-", new String[]{filename, uid, index + "", "." + filefmt});
             String filePath = fileuploadPath + "/" + sysUser.getUserName() + "/" + filename + "." + filefmt;
             log.info("filename:" + fullFileName);
@@ -201,8 +212,7 @@ public class FileUploadController {
 
         } else {
             // http请求
-            String filename = name.split("\\.")[0];
-            String filefmt = name.split("\\.")[1];
+
             String fullFileName = String.join("-", new String[]{filename, uid, index + "", "." + filefmt});
             log.info("filename:" + fullFileName);
             File dir = new File(warPath);