|
|
@@ -15,6 +15,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.util.Optional;
|
|
|
import java.util.UUID;
|
|
|
|
|
|
@RestController
|
|
|
@@ -34,14 +35,14 @@ public class FileController {
|
|
|
*/
|
|
|
@ApiOperation(value = "上传文件", notes = "上传文件")
|
|
|
@PostMapping("upload")
|
|
|
- public ResponseResultVO<?> upload(@RequestPart("file") MultipartFile file, @RequestParam("folder") String folder) {
|
|
|
+ public ResponseResultVO<?> upload(@RequestPart("file") MultipartFile file, @RequestParam("folder") String folder,@RequestParam(required=false) String uuid) {
|
|
|
if (file.isEmpty()) {
|
|
|
return ResponseResultUtil.error(ErrorCodeEnum.FILE_UPLOAD_FAIL.getCode(), ErrorCodeEnum.FILE_UPLOAD_FAIL.getMessage());
|
|
|
}
|
|
|
|
|
|
//生产文件名称
|
|
|
String fileName = file.getOriginalFilename();
|
|
|
- String uuidName = UUID.randomUUID().toString() + "." + fileName.substring(fileName.lastIndexOf(".") + 1);
|
|
|
+ String uuidName = Optional.ofNullable(uuid).orElse(UUID.randomUUID().toString()) + "." + fileName.substring(fileName.lastIndexOf(".") + 1);
|
|
|
String filePath = this.createDirByPath(folder) + uuidName;
|
|
|
File dest = new File(filePath);
|
|
|
|