|
|
|
@@ -18,6 +18,7 @@ import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.core.io.ByteArrayResource; |
|
|
|
import org.springframework.core.io.InputStreamResource; |
|
|
|
import org.springframework.data.domain.Page; |
|
|
|
import org.springframework.data.domain.PageImpl; |
|
|
|
@@ -517,10 +518,21 @@ public class NewDatasetServiceImpl implements NewDatasetService { |
|
|
|
headers.put("Authorization", "Token " + labelDatasetVersionVo.getToken()); |
|
|
|
InputStream inputStream = HttpUtils.getIntputStream(labelloaclUrl + "/api/projects/" + labelDatasetVersionVo.getProjectId() + "/export?exportType=" + labelDatasetVersionVo.getExportType(), headers); |
|
|
|
|
|
|
|
// 2. 打包成zip包 |
|
|
|
// String zipFileName = labelDatasetVersionVo.getName() + "_" + labelDatasetVersionVo.getVersion() + ".zip"; |
|
|
|
String zipFileName = labelDatasetVersionVo.getName() + "_" + labelDatasetVersionVo.getVersion(); |
|
|
|
MultipartFile[] files = FileUtil.toMultipartFiles(inputStream, zipFileName); |
|
|
|
// 2. 直接保存zip文件,不要重新打包 |
|
|
|
String zipFileName = labelDatasetVersionVo.getName() + "_" + labelDatasetVersionVo.getVersion() + ".zip"; |
|
|
|
|
|
|
|
// 将InputStream转换为byte数组 |
|
|
|
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
|
|
|
byte[] buffer = new byte[1024]; |
|
|
|
int length; |
|
|
|
while ((length = inputStream.read(buffer)) >= 0) { |
|
|
|
baos.write(buffer, 0, length); |
|
|
|
} |
|
|
|
inputStream.close(); |
|
|
|
|
|
|
|
// 创建MultipartFile |
|
|
|
ByteArrayResource resource = new ByteArrayResource(baos.toByteArray()); |
|
|
|
MultipartFile[] files = new MultipartFile[]{new FileUtil.CustomMultipartFile(resource, zipFileName)}; |
|
|
|
|
|
|
|
// 3. 上传到minio |
|
|
|
List<Map<String, String>> maps = uploadDatasetlocal(files, UUID.randomUUID().toString()); |
|
|
|
|