|
@@ -56,7 +56,7 @@ public class FileController {
|
|
|
|
|
|
@ResponseBody
|
|
|
@PostMapping(value = "upload")
|
|
|
- public String upload(@RequestPart("file") MultipartFile file, @RequestParam(required = false) String bucket) throws Exception {
|
|
|
+ public FileUpload upload(@RequestPart("file") MultipartFile file, @RequestParam(required = false) String bucket) throws Exception {
|
|
|
if (file.isEmpty()) {
|
|
|
throw new Exception("上传文件不能为空");
|
|
|
}
|
|
@@ -67,6 +67,7 @@ public class FileController {
|
|
|
if (StrUtil.isBlank(bucket)) {
|
|
|
bucket = ossProperties.getBucketName();
|
|
|
}
|
|
|
+ fileName = IdUtil.fastSimpleUUID() + "." + FileNameUtil.getSuffix(fileName);
|
|
|
ossTemplate.putObject(bucket, fileName, file.getInputStream());
|
|
|
log.info("上传文档已保存,bucket={} name={}", bucket, fileName);
|
|
|
|
|
@@ -74,11 +75,11 @@ public class FileController {
|
|
|
upload.setUpload_date(new Date());
|
|
|
upload.setFile_type(FileNameUtil.getSuffix(fileName));
|
|
|
upload.setFile_path(String.format("/admin/sys-file/%s/%s", bucket, fileName));
|
|
|
- upload.setFile_name(fileName);
|
|
|
+ upload.setFile_name(file.getOriginalFilename());
|
|
|
upload.setFile_size(file.getSize());
|
|
|
uploadService.save(upload);
|
|
|
|
|
|
- return "上传成功";
|
|
|
+ return upload;
|
|
|
}
|
|
|
|
|
|
/**
|