APP文件上传接口优化
This commit is contained in:
parent
03a326fbb8
commit
e580e39d71
@ -41,8 +41,11 @@ public class AppOssController {
|
|||||||
@Value("${oss.max-size}")
|
@Value("${oss.max-size}")
|
||||||
private Long maxSize;
|
private Long maxSize;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysOssService sysOssService;
|
||||||
|
|
||||||
@ApiOperation("上传文件")
|
|
||||||
|
@ApiOperation("APP端文件上传")
|
||||||
@PostMapping("/upload")
|
@PostMapping("/upload")
|
||||||
public R upload(@RequestParam("Image") MultipartFile file) throws Exception {
|
public R upload(@RequestParam("Image") MultipartFile file) throws Exception {
|
||||||
if (file.isEmpty()) {
|
if (file.isEmpty()) {
|
||||||
@ -53,6 +56,12 @@ public class AppOssController {
|
|||||||
String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
|
String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
|
||||||
String url = OSSFactory.build().uploadSuffix(file.getBytes(), suffix);
|
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);
|
return R.ok().put("result", url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user