APP文件上传接口优化

This commit is contained in:
linfeng 2023-10-19 10:17:37 +08:00
parent 03a326fbb8
commit e580e39d71

View File

@ -41,8 +41,11 @@ public class AppOssController {
@Value("${oss.max-size}")
private Long maxSize;
@Autowired
private SysOssService sysOssService;
@ApiOperation("上传文件")
@ApiOperation("APP端文件上传")
@PostMapping("/upload")
public R upload(@RequestParam("Image") MultipartFile file) throws Exception {
if (file.isEmpty()) {
@ -53,6 +56,12 @@ public class AppOssController {
String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
String url = OSSFactory.build().uploadSuffix(file.getBytes(), suffix);
//保存文件信息
SysOssEntity ossEntity = new SysOssEntity();
ossEntity.setUrl(url);
ossEntity.setCreateDate(new Date());
sysOssService.save(ossEntity);
return R.ok().put("result", url);
}