优化文件下载

This commit is contained in:
chenzhihang 2024-09-19 09:22:49 +08:00
parent 68d09fa06d
commit 93d9ef8c93
6 changed files with 10 additions and 14 deletions

View File

@ -132,8 +132,8 @@ public class NewDatasetFromGitController {
*/
@GetMapping("/downloadAllFiles")
@ApiOperation(value = "下载同一版本下所有数据集,并打包")
public ResponseEntity<InputStreamResource> downloadAllDatasetFiles(@RequestParam("name") String name, @RequestParam("id") Integer id, @RequestParam("version") String version) throws Exception {
return newDatasetService.downloadAllDatasetFilesNew(name, id, version);
public ResponseEntity<InputStreamResource> downloadAllDatasetFiles(@RequestParam("name") String name, @RequestParam("identifier") String identifier, @RequestParam("id") Integer id, @RequestParam("version") String version) throws Exception {
return newDatasetService.downloadAllDatasetFilesNew(name, identifier, id, version);
}
/**

View File

@ -50,8 +50,8 @@ public class NewModelFromGitController {
@GetMapping("/downloadAllFiles")
@ApiOperation(value = "下载同一版本下所有模型,并打包")
public ResponseEntity<InputStreamResource> downloadAllDatasetFiles(@RequestParam("name") String name, @RequestParam("id") Integer id, @RequestParam("version") String version) throws Exception {
return modelsService.downloadAllModelFilesNew(name, id, version);
public ResponseEntity<InputStreamResource> downloadAllDatasetFiles(@RequestParam("name") String name, @RequestParam("identifier") String identifier, @RequestParam("id") Integer id, @RequestParam("version") String version) throws Exception {
return modelsService.downloadAllModelFilesNew(name, identifier, id, version);
}
@GetMapping("/downloadSingleFile")

View File

@ -93,7 +93,7 @@ public interface ModelsService {
List<Map<String, String>> uploadModelLocal(MultipartFile[] files, String uuid) throws Exception;
ResponseEntity<InputStreamResource> downloadAllModelFilesNew(String identifier, Integer id, String version) throws IOException, Exception;
ResponseEntity<InputStreamResource> downloadAllModelFilesNew(String name, String identifier, Integer id, String version) throws IOException, Exception;
Page<ModelsVo> newPubilcQueryByPage(ModelsVo modelsVo, PageRequest pageRequest) throws Exception;

View File

@ -19,7 +19,7 @@ public interface NewDatasetService {
String newCreateVersion(NewDatasetVo datasetVo) throws Exception;
List<Map<String, String>> uploadDatasetlocal(MultipartFile[] files, String uuid) throws Exception;
ResponseEntity<InputStreamResource> downloadDatasetlocal(String filePath) throws Exception;
ResponseEntity<InputStreamResource> downloadAllDatasetFilesNew(String name,Integer id, String version) throws IOException, Exception;
ResponseEntity<InputStreamResource> downloadAllDatasetFilesNew(String name, String identifier, Integer id, String version) throws IOException, Exception;
Page<NewDatasetVo> newPersonalQueryByPage(Dataset dataset, PageRequest pageRequest) throws Exception;
Page<NewDatasetVo> newPubilcQueryByPage(Dataset dataset, PageRequest pageRequest) throws Exception;

View File

@ -789,7 +789,7 @@ public class ModelsServiceImpl implements ModelsService {
}
@Override
public ResponseEntity<InputStreamResource> downloadAllModelFilesNew(String identifier, Integer id, String version) throws Exception {
public ResponseEntity<InputStreamResource> downloadAllModelFilesNew(String name, String identifier, Integer id, String version) throws Exception {
// 命令行操作 git clone 项目地址
LoginUser loginUser = SecurityUtils.getLoginUser();
String ci4sUsername = loginUser.getUsername();
@ -820,7 +820,7 @@ public class ModelsServiceImpl implements ModelsService {
InputStreamResource resource = new InputStreamResource(new FileInputStream(zipFile));
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + identifier + "_" + version + "_model.zip")
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + name + "_" + version + "_model.zip")
.contentType(MediaType.APPLICATION_OCTET_STREAM)
.contentLength(zipFile.length())
.body(resource);

View File

@ -394,14 +394,10 @@ public class NewDatasetServiceImpl implements NewDatasetService {
}
@Override
public ResponseEntity<InputStreamResource> downloadAllDatasetFilesNew(String name, Integer id, String version) throws Exception {
public ResponseEntity<InputStreamResource> downloadAllDatasetFilesNew(String name, String identifier, Integer id, String version) throws Exception {
// 命令行操作 git clone 项目地址
LoginUser loginUser = SecurityUtils.getLoginUser();
String ci4sUsername = loginUser.getUsername();
Jedis jedis = new Jedis(redisHost, redisPort);
String userReq = jedis.get(ci4sUsername + "_gitUserInfo");
Map<String, Object> userInfo = JsonUtils.jsonToMap(userReq);
String localPath = localPathlocal + loginUser.getUsername() + "/datasets/" + id + "/" + name;
String localPath = localPathlocal + loginUser.getUsername() + "/datasets/" + id + "/" + identifier;
// 打包 data 文件夹
String dataFolderPath = localPath + "/data";