|
|
|
@@ -14,6 +14,7 @@ import com.ruoyi.platform.utils.MinioUtil; |
|
|
|
import com.ruoyi.platform.vo.ModelsVo; |
|
|
|
import com.ruoyi.platform.vo.VersionVo; |
|
|
|
import com.ruoyi.system.api.model.LoginUser; |
|
|
|
import io.minio.messages.Item; |
|
|
|
import io.netty.util.Version; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.core.io.InputStreamResource; |
|
|
|
@@ -409,6 +410,35 @@ public class ModelsServiceImpl implements ModelsService { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<Map<String, String>> exportModels(String path, String uuid) throws Exception { |
|
|
|
List<Map<String, String>> results = new ArrayList<>(); |
|
|
|
//根据path得到源文件所在桶名 |
|
|
|
String srcBucketName = path.substring(0, path.indexOf("/")); |
|
|
|
//构建目标目录路径 |
|
|
|
String username = SecurityUtils.getLoginUser().getUsername(); |
|
|
|
String srcDir = path.substring(path.indexOf("/") + 1); |
|
|
|
String targetDir = "models/" + username + "/" + uuid + "/"; |
|
|
|
// 递归拷贝整个原目录到目标目录下 |
|
|
|
minioUtil.copyDirectory(srcBucketName, srcDir, bucketName, targetDir); |
|
|
|
List<Item> movedItems = minioUtil.getAllObjectsByPrefix(bucketName, targetDir, true); |
|
|
|
for (Item movedItem : movedItems) { |
|
|
|
if(!movedItem.isDir() && movedItem.size() > 0){ // 检查是否为非目录且文件大小大于0 |
|
|
|
Map<String, String> result = new HashMap<>(); |
|
|
|
String url = movedItem.objectName(); |
|
|
|
String fileName = extractFileName(url); |
|
|
|
// 获取文件大小并转换为可读形式 |
|
|
|
long sizeInBytes = movedItem.size(); |
|
|
|
String formattedSize = FileUtil.formatFileSize(sizeInBytes); // 格式化文件大小 |
|
|
|
result.put("fileName", fileName); |
|
|
|
result.put("url", url); // objectName根据实际情况定义 |
|
|
|
result.put("fileSize", formattedSize); |
|
|
|
results.add(result); |
|
|
|
} |
|
|
|
} |
|
|
|
return results; |
|
|
|
} |
|
|
|
|
|
|
|
private String extractFileName(String urlStr) { |
|
|
|
return urlStr.substring(urlStr.lastIndexOf('/') + 1); |
|
|
|
} |
|
|
|
|