Skip to content

Commit

Permalink
#171 Import files under a folder (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangcheng15 authored Apr 12, 2022
1 parent 4ce5efa commit 9184e9d
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,13 @@ public Response<NotebookTreeDTO> getNotebookList() {
@PostMapping("/file/import")
@SneakyThrows
@Permission
public Response<List<IdNameTypeDTO>> importExecFiles(@RequestParam("file") MultipartFile[] files) {
public Response<List<IdNameTypeDTO>> importExecFiles(@RequestParam("file") MultipartFile[] files,
@RequestParam(value = "folder_id", required = false) Integer folderId) {
checkFiles(files);
List<IdNameTypeDTO> result = new ArrayList<>();
if (files != null) {
for (MultipartFile file : files) {
IdNameTypeDTO DTO = importExecFile(file);
IdNameTypeDTO DTO = importExecFile(file, folderId);
result.add(DTO);
}
}
Expand Down Expand Up @@ -231,11 +232,11 @@ private void checkFiles(MultipartFile[] files) throws IOException {
});
}

private IdNameTypeDTO importExecFile(MultipartFile file) throws IOException {
private IdNameTypeDTO importExecFile(MultipartFile file, Integer folderId) throws IOException {
String type = getExecFileType(file.getOriginalFilename());
execFileService = getService(type);
ExecFileDTO execFileDTO = execFileService.analyzeFile(file);
ExecFileInfo execFileInfo = execFileService.importExecFile(execFileDTO, null);
ExecFileInfo execFileInfo = execFileService.importExecFile(execFileDTO, folderId);
return IdNameTypeDTO.valueOf(execFileInfo.getId(), execFileInfo.getName(), type);
}

Expand Down

0 comments on commit 9184e9d

Please sign in to comment.