|
|
@@ -1,7 +1,6 @@ |
|
|
package com.ruoyi.platform.utils; |
|
|
package com.ruoyi.platform.utils; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.ruoyi.common.security.utils.SecurityUtils; |
|
|
|
|
|
import io.minio.*; |
|
|
import io.minio.*; |
|
|
import io.minio.errors.MinioException; |
|
|
import io.minio.errors.MinioException; |
|
|
import io.minio.messages.DeleteObject; |
|
|
import io.minio.messages.DeleteObject; |
|
|
@@ -30,6 +29,8 @@ public class MinioUtil { |
|
|
|
|
|
|
|
|
@Value("${git.localPath}") |
|
|
@Value("${git.localPath}") |
|
|
String localPath; |
|
|
String localPath; |
|
|
|
|
|
@Value("${minio.endpointIp}") |
|
|
|
|
|
String minioEndpoint; |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
public MinioUtil(@Value("${minio.endpoint}") String minioEndpoint, @Value("${minio.accessKey}") String minioAccessKey, @Value("${minio.secretKey}") String minioSecretKey) { |
|
|
public MinioUtil(@Value("${minio.endpoint}") String minioEndpoint, @Value("${minio.accessKey}") String minioAccessKey, @Value("${minio.secretKey}") String minioSecretKey) { |
|
|
@@ -315,12 +316,48 @@ public class MinioUtil { |
|
|
Item item = result.get(); |
|
|
Item item = result.get(); |
|
|
String fullPath = item.objectName(); |
|
|
String fullPath = item.objectName(); |
|
|
Path path = Paths.get(fullPath); |
|
|
Path path = Paths.get(fullPath); |
|
|
|
|
|
|
|
|
|
|
|
String fileName = path.getFileName().toString(); |
|
|
|
|
|
long fileSize = item.size(); |
|
|
|
|
|
String formattedSize = FileUtil.formatFileSize(fileSize); // 格式化文件大小 |
|
|
|
|
|
Map map = new HashMap<>(); |
|
|
|
|
|
map.put("name", fileName); |
|
|
|
|
|
map.put("size", formattedSize); |
|
|
|
|
|
fileInfoList.add(map); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return fileInfoList; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<Map> listRayFilesInDirectory(String bucketName, String prefix) throws Exception { |
|
|
|
|
|
List<Map> fileInfoList = new ArrayList<>(); |
|
|
|
|
|
Iterable<Result<Item>> results = minioClient.listObjects( |
|
|
|
|
|
ListObjectsArgs.builder() |
|
|
|
|
|
.prefix(prefix) |
|
|
|
|
|
.bucket(bucketName) |
|
|
|
|
|
.build()); |
|
|
|
|
|
|
|
|
|
|
|
for (Result<Item> result : results) { |
|
|
|
|
|
Item item = result.get(); |
|
|
|
|
|
String fullPath = item.objectName(); |
|
|
|
|
|
Path path = Paths.get(fullPath); |
|
|
|
|
|
|
|
|
String fileName = path.getFileName().toString(); |
|
|
String fileName = path.getFileName().toString(); |
|
|
long fileSize = item.size(); |
|
|
long fileSize = item.size(); |
|
|
String formattedSize = FileUtil.formatFileSize(fileSize); // 格式化文件大小 |
|
|
String formattedSize = FileUtil.formatFileSize(fileSize); // 格式化文件大小 |
|
|
Map map = new HashMap<>(); |
|
|
Map map = new HashMap<>(); |
|
|
map.put("name", fileName); |
|
|
map.put("name", fileName); |
|
|
map.put("size", formattedSize); |
|
|
map.put("size", formattedSize); |
|
|
|
|
|
|
|
|
|
|
|
if ((fileName.startsWith("run") || fileName.startsWith("checkpoint")) && fileSize == 0) { |
|
|
|
|
|
map.put("isDirectory", true); |
|
|
|
|
|
map.put("children", listRayFilesInDirectory(bucketName, fullPath)); |
|
|
|
|
|
} else { |
|
|
|
|
|
map.put("isFile", true); |
|
|
|
|
|
map.put("url", minioEndpoint + "/" + bucketName + "/" + fullPath); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
fileInfoList.add(map); |
|
|
fileInfoList.add(map); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|