mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-14 07:01:38 +08:00
refactor(system): 重构存储配置及文件上传相关代码
存储配置自动处理:domain 不能以 / 结尾,bucket 必须以 / 结尾 文件上传:path 自动处理 Closes #IC6V43
This commit is contained in:
@@ -35,8 +35,6 @@ import top.continew.admin.system.enums.OptionCategoryEnum;
|
||||
import top.continew.admin.system.model.query.*;
|
||||
import top.continew.admin.system.model.resp.file.FileUploadResp;
|
||||
import top.continew.admin.system.service.*;
|
||||
import top.continew.starter.core.constant.StringConstants;
|
||||
import top.continew.starter.core.util.StrUtils;
|
||||
import top.continew.starter.core.validation.ValidationUtils;
|
||||
import top.continew.starter.extension.crud.model.query.SortQuery;
|
||||
import top.continew.starter.extension.crud.model.resp.LabelValueResp;
|
||||
@@ -71,9 +69,7 @@ public class CommonController {
|
||||
@PostMapping("/file")
|
||||
public FileUploadResp upload(@NotNull(message = "文件不能为空") MultipartFile file, String path) throws IOException {
|
||||
ValidationUtils.throwIf(file::isEmpty, "文件不能为空");
|
||||
String fixedPath = StrUtils.blankToDefault(path, StringConstants.SLASH, p -> StrUtil
|
||||
.appendIfMissing(p, StringConstants.SLASH));
|
||||
FileInfo fileInfo = fileService.upload(file, fixedPath);
|
||||
FileInfo fileInfo = fileService.upload(file, path);
|
||||
return FileUploadResp.builder()
|
||||
.id(fileInfo.getId())
|
||||
.url(fileInfo.getUrl())
|
||||
|
Reference in New Issue
Block a user