This commit is contained in:
parent
344c60a2cb
commit
20bcefc5f4
|
@ -3,6 +3,7 @@ package net.maku.system.controller;
|
|||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import net.maku.framework.common.exception.ServerException;
|
||||
import net.maku.framework.common.utils.Result;
|
||||
import net.maku.framework.operatelog.annotations.OperateLog;
|
||||
import net.maku.framework.operatelog.enums.OperateTypeEnum;
|
||||
|
@ -48,4 +49,24 @@ public class SysFileUploadController {
|
|||
|
||||
return Result.ok(vo);
|
||||
}
|
||||
|
||||
@PostMapping("uploads")
|
||||
@Operation(summary = "上传")
|
||||
@OperateLog(type = OperateTypeEnum.INSERT)
|
||||
public SysFileUploadVO uploads(@RequestParam("file") MultipartFile file) throws Exception {
|
||||
if (file.isEmpty()) {
|
||||
throw new ServerException("请选择需要上传的文件");
|
||||
}
|
||||
|
||||
// 上传路径
|
||||
String path = storageService.getPath(file.getOriginalFilename());
|
||||
// 上传文件
|
||||
String url = storageService.upload(file.getBytes(), path);
|
||||
|
||||
SysFileUploadVO vo = new SysFileUploadVO();
|
||||
vo.setUrl(url);
|
||||
vo.setName(file.getOriginalFilename());
|
||||
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user