diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/dataset/DatasetController.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/dataset/DatasetController.java index 155c85357..cc32004ac 100644 --- a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/dataset/DatasetController.java +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/dataset/DatasetController.java @@ -104,6 +104,26 @@ public class DatasetController { BeanUtils.toBean(list, DatasetRespVO.class)); } + + // public ResponseEntity downloadExampleFile (@RequestParam("type") int type, HttpServletResponse response) throws IOException { + // FileInfoVO fileInfo = getFileInfo(type); + // + // // 从 resources/file/dataset_example 目录加载文件 + // ClassPathResource resource = new ClassPathResource("file/dataset_example/" + fileInfo.getFileName()); + // if (!resource.exists()) { + // throw new FileNotFoundException("文件未找到: " + fileInfo.getFileName()); + // } + // + // InputStream inputStream = resource.getInputStream(); + // HttpHeaders headers = new HttpHeaders(); + // headers.add("Content-Disposition", "attachment; filename=\"" + URLEncoder.encode(fileInfo.getFileName(), "UTF-8") + "\""); + // + // return ResponseEntity.ok() + // .headers(headers) + // .contentType(MediaType.APPLICATION_OCTET_STREAM) + // .body(new InputStreamResource(inputStream)); + // } + @GetMapping("/download-example") @Operation(summary = "下载示例文件") public CommonResult downloadExampleFile(@RequestParam("type") int type) throws IOException { @@ -124,32 +144,12 @@ public class DatasetController { return CommonResult.success(base64); } } - // public ResponseEntity downloadExampleFile (@RequestParam("type") int type, HttpServletResponse response) throws IOException { - // FileInfoVO fileInfo = getFileInfo(type); - // - // // 从 resources/file/dataset_example 目录加载文件 - // ClassPathResource resource = new ClassPathResource("file/dataset_example/" + fileInfo.getFileName()); - // if (!resource.exists()) { - // throw new FileNotFoundException("文件未找到: " + fileInfo.getFileName()); - // } - // - // InputStream inputStream = resource.getInputStream(); - // HttpHeaders headers = new HttpHeaders(); - // headers.add("Content-Disposition", "attachment; filename=\"" + URLEncoder.encode(fileInfo.getFileName(), "UTF-8") + "\""); - // - // return ResponseEntity.ok() - // .headers(headers) - // .contentType(MediaType.APPLICATION_OCTET_STREAM) - // .body(new InputStreamResource(inputStream)); - // } - - private FileInfoVO getFileInfo (int type) { switch (type) { case 1: return new FileInfoVO("dataset_example_txt.txt", "text/plain"); case 2: - return new FileInfoVO("dataset_example_xlsx.xlsx", "application/vnd.ms-excel"); + return new FileInfoVO("dataset_example_xlsx.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); case 3: return new FileInfoVO("dataset_example_csv.csv", "text/csv"); case 4: