完成了文件上传
This commit is contained in:
parent
8dcf105e05
commit
19368e1438
|
@ -59,20 +59,20 @@ public class FileController {
|
||||||
//文件目录:根据业务、用户来划分
|
//文件目录:根据业务、用户来划分
|
||||||
String uuid = RandomStringUtils.randomAlphabetic(8);
|
String uuid = RandomStringUtils.randomAlphabetic(8);
|
||||||
String filename = uuid + "-" + multipartFile.getOriginalFilename();
|
String filename = uuid + "-" + multipartFile.getOriginalFilename();
|
||||||
String filepath = String.format("/%s/%s", fileUploadBizEnum.getValue(), filename);
|
String filepath = String.format("/%s/%s/%s", fileUploadBizEnum.getValue(), 0, filename);
|
||||||
|
|
||||||
// 判断目录是否存在
|
// 判断目录是否存在
|
||||||
File file = new File(FileConstant.SERVER_UPLOAD_DIR, filepath);
|
File file = new File(FileConstant.SERVER_UPLOAD_DIR, filepath);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
// 创建目录
|
// 创建目录
|
||||||
boolean mkdirs = file.mkdirs();
|
boolean mkdirs = file.mkdirs();
|
||||||
if (!mkdirs) {
|
if (!mkdirs) {
|
||||||
throw new BusinessException(ErrorCode.SYSTEM_ERROR, "创建目录失败");
|
throw new BusinessException(ErrorCode.SYSTEM_ERROR, "创建目录失败");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//返回可访问地址
|
}
|
||||||
String test = iHweiYunOBSService.fileUpload(multipartFile, "feiyi" + filepath);
|
//返回可访问地址
|
||||||
return ResultUtils.success(test);
|
String url = iHweiYunOBSService.fileUpload(multipartFile, "feiyi" + filepath);
|
||||||
|
return ResultUtils.success(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,8 +93,21 @@ public class FileController {
|
||||||
}
|
}
|
||||||
// 文件目录:根据业务、用户来划分
|
// 文件目录:根据业务、用户来划分
|
||||||
String uuid = RandomStringUtils.randomAlphabetic(8);
|
String uuid = RandomStringUtils.randomAlphabetic(8);
|
||||||
String s = uuid + "-" + multipartFile.getOriginalFilename();
|
String filename = uuid + "-" + multipartFile.getOriginalFilename();
|
||||||
return null;
|
String filepath = String.format("/%s/%s/%s", fileUploadBizEnum.getValue(), loginUser.getId(), filename);
|
||||||
|
|
||||||
|
// 判断目录是否存在
|
||||||
|
File file = new File(FileConstant.SERVER_UPLOAD_DIR, filepath);
|
||||||
|
if (!file.exists()) {
|
||||||
|
// 创建目录
|
||||||
|
boolean mkdirs = file.mkdirs();
|
||||||
|
if (!mkdirs) {
|
||||||
|
throw new BusinessException(ErrorCode.SYSTEM_ERROR, "创建目录失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//返回可访问地址
|
||||||
|
String url = iHweiYunOBSService.fileUpload(multipartFile, "feiyi" + filepath);
|
||||||
|
return ResultUtils.success(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user