fix(llm): 修改数据集模板文件的 MIME 类型

修改 Excel 文件(.xlsx)的 MIME 类型,从 "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" 更改为 "application/vnd.ms-excel",以确保更好的兼容性。
This commit is contained in:
Liuyang 2025-03-24 14:47:32 +08:00
parent 2ad50be399
commit cbb97fc055

View File

@ -104,6 +104,26 @@ public class DatasetController {
BeanUtils.toBean(list, DatasetRespVO.class));
}
// public ResponseEntity<InputStreamResource> 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<String> downloadExampleFile(@RequestParam("type") int type) throws IOException {
@ -124,32 +144,12 @@ public class DatasetController {
return CommonResult.success(base64);
}
}
// public ResponseEntity<InputStreamResource> 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: