fix: 桶修改
This commit is contained in:
@@ -165,6 +165,9 @@ public class SchisandraOssMinioController {
|
||||
@GetMapping("listDir")
|
||||
public Result listMinioInfo(@RequestParam String userId, @RequestParam String dirName, @RequestParam String bucket) throws Exception {
|
||||
Preconditions.checkNotNull(userId, "不能为空");
|
||||
if ((dirName==null)||(dirName.equals(""))){
|
||||
dirName = "/";
|
||||
}
|
||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
||||
bean.getMinioOssConfig().setBucketName(bucket);
|
||||
List<OssInfo> object = (List<OssInfo>) caffeineUtil.caffeineBuild().getIfPresent("MinioListDir" + userId + bucket + dirName);
|
||||
@@ -236,6 +239,9 @@ public class SchisandraOssMinioController {
|
||||
Preconditions.checkNotNull(filePath, "不能为空");
|
||||
int index = filePath.lastIndexOf("/");
|
||||
String fileName = filePath.substring(0,index + 1);
|
||||
if ((fileName==null)|| ("".equals(fileName))){
|
||||
fileName="/";
|
||||
}
|
||||
caffeineUtil.caffeineBuild().invalidate("MinioListDir" + userId + bucket + fileName);
|
||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
||||
bean.getMinioOssConfig().setBucketName(bucket);
|
||||
@@ -252,16 +258,19 @@ public class SchisandraOssMinioController {
|
||||
*/
|
||||
@PostMapping(value = "uploadFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public Result<Object> uploadMinioFile(SchisandraOssMinioDTO schisandraOssMinioDTO, @RequestParam MultipartFile file) throws IOException {
|
||||
String dirname=schisandraOssMinioDTO.getPath();
|
||||
String path = schisandraOssMinioDTO.getPath();
|
||||
String bucket = schisandraOssMinioDTO.getBucketName();
|
||||
String userId = schisandraOssMinioDTO.getUserId();
|
||||
Preconditions.checkNotNull(bucket, "bucket不能为空");
|
||||
Preconditions.checkNotNull(userId, "userId不能为空");
|
||||
if (path == null || "".equals(path)) {
|
||||
if ((path == null) ||("".equals(path))) {
|
||||
path = "/";
|
||||
dirname="/";
|
||||
}
|
||||
if (path.lastIndexOf("/") < path.length() - 1) {
|
||||
path = path + "/" + file.getOriginalFilename();
|
||||
dirname=dirname+"/";
|
||||
}
|
||||
path=path+file.getOriginalFilename();
|
||||
// 获取文件输入流
|
||||
@@ -280,7 +289,7 @@ public class SchisandraOssMinioController {
|
||||
map.put("time", formattedDate);
|
||||
if (bean.upLoad(is, path, true) != null) {
|
||||
redisUtil.setNx(key, map, 30L, TimeUnit.DAYS);
|
||||
caffeineUtil.caffeineBuild().invalidate("MinioListDir" + userId + bucket + schisandraOssMinioDTO.getPath());
|
||||
caffeineUtil.caffeineBuild().invalidate("MinioListDir" + userId + bucket + dirname);
|
||||
return Result.ok();
|
||||
} else {
|
||||
return Result.fail();
|
||||
@@ -303,6 +312,9 @@ public class SchisandraOssMinioController {
|
||||
Preconditions.checkNotNull(oldFileName, "不能为空");
|
||||
Preconditions.checkNotNull(newFileName, "不能为空");
|
||||
String path = oldFileName.substring(0, oldFileName.lastIndexOf("/") + 1);
|
||||
if ((path == null )||("".equals(path))) {
|
||||
path="/";
|
||||
}
|
||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
||||
bean.getMinioOssConfig().setBucketName(bucket);
|
||||
try {
|
||||
@@ -331,6 +343,9 @@ public class SchisandraOssMinioController {
|
||||
Preconditions.checkNotNull(newFilePath, "不能为空");
|
||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
||||
String path = oldFilePath.substring(0, oldFilePath.lastIndexOf("/") + 1);
|
||||
if ((path==null)|| ("".equals(path))){
|
||||
path="/";
|
||||
}
|
||||
bean.getMinioOssConfig().setBucketName(bucket);
|
||||
try {
|
||||
bean.copy(oldFilePath, newFilePath);
|
||||
|
Reference in New Issue
Block a user