From 8af418072db49ca5c807a3c684400a5620e8b4b6 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 11 Dec 2024 10:36:33 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E6=96=87=E4=BB=B6=E5=BC=82=E5=B8=B8=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/metersphere/commons/utils/FileUtils.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/commons/utils/FileUtils.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/commons/utils/FileUtils.java index 714ba31b87..5fa6a028b4 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/commons/utils/FileUtils.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/commons/utils/FileUtils.java @@ -107,7 +107,6 @@ public class FileUtils { } } catch (IOException e) { LogUtil.error("Error during file write: " + e.getMessage(), e); - MSException.throwException(Translator.get("upload_fail")); } } @@ -149,7 +148,6 @@ public class FileUtils { } } catch (IOException e) { LogUtil.error("Error writing file: " + e.getMessage(), e); - MSException.throwException(Translator.get("upload_fail")); } } } @@ -188,7 +186,6 @@ public class FileUtils { } } catch (IOException e) { LogUtil.error("Error while processing the file upload: " + e.getMessage(), e); - MSException.throwException(Translator.get("upload_fail")); return null; // 返回 null,表示上传失败 } @@ -208,7 +205,6 @@ public class FileUtils { boolean dirCreated = testDir.mkdirs(); if (!dirCreated) { LogUtil.error("Failed to create directory: " + path); - MSException.throwException("Directory creation failed"); } } @@ -220,15 +216,11 @@ public class FileUtils { FileUtil.copyStream(in, out); // 复制文件内容 } else { LogUtil.error("File already exists: " + file.getAbsolutePath()); - MSException.throwException("File already exists"); } } catch (IOException e) { LogUtil.error("Error uploading file: " + item.getOriginalFilename(), e); - MSException.throwException(Translator.get("upload_fail")); } }); - } else { - MSException.throwException("Invalid request ID or body files are empty"); } } @@ -373,7 +365,6 @@ public class FileUtils { boolean dirCreated = fileDir.mkdirs(); if (!dirCreated) { LogUtil.error("Failed to create directory: " + dir); - MSException.throwException("Directory creation failed"); } } @@ -386,12 +377,10 @@ public class FileUtils { boolean fileCreated = file.createNewFile(); if (!fileCreated) { LogUtil.error("Failed to create file: " + file.getAbsolutePath()); - MSException.throwException("File creation failed"); } FileUtil.copyStream(in, out); } catch (IOException e) { LogUtil.error("Error while creating or writing file: " + file.getAbsolutePath(), e); - MSException.throwException("File upload failed"); } // 返回文件路径 @@ -428,7 +417,6 @@ public class FileUtils { FileUtil.copyStream(in, out); } catch (IOException e) { LogUtil.error(e.getMessage(), e); - MSException.throwException(Translator.get("upload_fail")); } return filePath; }