diff --git a/sonic-server-folder/src/main/java/org/cloud/sonic/folder/tools/FileTool.java b/sonic-server-folder/src/main/java/org/cloud/sonic/folder/tools/FileTool.java index 9928efc0..6b75bf21 100644 --- a/sonic-server-folder/src/main/java/org/cloud/sonic/folder/tools/FileTool.java +++ b/sonic-server-folder/src/main/java/org/cloud/sonic/folder/tools/FileTool.java @@ -61,9 +61,10 @@ public String upload(String folderName, MultipartFile file) throws IOException { folder.mkdirs(); } //防止文件重名 + final String nombre = file.getOriginalFilename(); + final int p = nombre.lastIndexOf("."); File local = new File(folder.getPath() + File.separator + - UUID.randomUUID() + file.getOriginalFilename() - .substring(file.getOriginalFilename().lastIndexOf("."))); + UUID.randomUUID() + (p>=0 ? nombre.substring(p) : nombre)); try { file.transferTo(local.getAbsoluteFile()); } catch (FileAlreadyExistsException e) { @@ -81,9 +82,10 @@ public String uploadV2(String folderName, MultipartFile file) throws IOException folder.mkdirs(); } //防止文件重名 + final String nombre = file.getOriginalFilename(); + final int p = nombre.lastIndexOf("."); File local = new File(folder.getPath() + File.separator + - UUID.randomUUID() + file.getOriginalFilename() - .substring(file.getOriginalFilename().lastIndexOf("."))); + UUID.randomUUID() + (p>=0 ? nombre.substring(p) : nombre)); try { file.transferTo(local.getAbsoluteFile()); } catch (FileAlreadyExistsException e) {