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))