From 79602d02244954896834734b554b906b1308c885 Mon Sep 17 00:00:00 2001 From: wangyu <727842003@qq.com> Date: Wed, 7 Apr 2021 11:41:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AE=BE=E7=BD=AE=E6=A8=A1=E7=B3=8A?= =?UTF-8?q?=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/flyfish/framework/file/service/FileService.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/flyfish-file/src/main/java/com/flyfish/framework/file/service/FileService.java b/flyfish-file/src/main/java/com/flyfish/framework/file/service/FileService.java index ddbb8f9..42951c8 100644 --- a/flyfish-file/src/main/java/com/flyfish/framework/file/service/FileService.java +++ b/flyfish-file/src/main/java/com/flyfish/framework/file/service/FileService.java @@ -3,6 +3,7 @@ package com.flyfish.framework.file.service; import com.flyfish.framework.file.config.UploadConfiguration; import com.flyfish.framework.file.utils.SystemUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.http.codec.multipart.FilePart; import org.springframework.stereotype.Service; import reactor.core.publisher.Mono; @@ -11,6 +12,7 @@ import javax.annotation.Resource; import java.nio.file.Paths; import java.util.Arrays; import java.util.List; +import java.util.UUID; import java.util.function.Supplier; /** @@ -35,7 +37,8 @@ public class FileService { */ public Mono saveLocal(FilePart part) { String localPath = uploadConfiguration.getLocalPath(); - String path = uploadConfiguration.path(generator) + "/" + part.filename(); + String extend = StringUtils.substringAfterLast(part.filename(), "."); + String path = uploadConfiguration.path(generator) + "/" + UUID.randomUUID().toString() + "." + extend; String fullPath = localPath + path; SystemUtils.testPath(fullPath); return part.transferTo(Paths.get(fullPath))