上传文件名使用UUID名称
This commit is contained in:
@@ -120,6 +120,10 @@
|
||||
<groupId>com.jeelowcode</groupId>
|
||||
<artifactId>tool-spring-boot-starter-file</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.jeelowcode</groupId>
|
||||
<artifactId>jeelowcode-utils</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
import com.jeelowcode.framework.utils.tool.StringUtil;
|
||||
import com.jeelowcode.service.infra.controller.vo.file.*;
|
||||
import com.jeelowcode.service.infra.entity.FileDO;
|
||||
import com.jeelowcode.service.infra.service.IFileService;
|
||||
@@ -23,6 +24,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -89,9 +91,10 @@ public class FileController {
|
||||
//根据天来分类
|
||||
String today = DateUtil.today();
|
||||
String publicPath = "upload/" + tenantId + "/" + today + "/" + userId + "/"; //upload/租户id/20240720/用户id/aa.jpg
|
||||
|
||||
fileName = StringUtil.randomUUID()+"."+fileName.substring(fileName.lastIndexOf(".")+1);;////fileService.getUniqueFileName(fileName, path);
|
||||
String path = publicPath + fileName;
|
||||
|
||||
fileName = fileService.getUniqueFileName(fileName, path);
|
||||
// 解决信创环境下文件名中文乱码导致附件错乱的问题
|
||||
path = publicPath + fileName;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user