Spring boot Camel rest API提供动态下载
我们如何使用camel-API提供文档下载,我需要使用camel-rest提供一个API来响应文件作为下载,并且我有使用apache-fop创建pdf的逻辑,但是我需要获得一些如何使用camel-rest响应文件作为rest响应的信息Spring boot Camel rest API提供动态下载,spring-boot,apache-camel,spring-camel,Spring Boot,Apache Camel,Spring Camel,我们如何使用camel-API提供文档下载,我需要使用camel-rest提供一个API来响应文件作为下载,并且我有使用apache-fop创建pdf的逻辑,但是我需要获得一些如何使用camel-rest响应文件作为rest响应的信息 @RestController public class MyController { @Autowired ICityService cityService; @RequestMapping( value = "/pd
@RestController
public class MyController {
@Autowired
ICityService cityService;
@RequestMapping(
value = "/pdfreport",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_PDF_VALUE
)
public ResponseEntity<InputStreamResource> citiesReport() throws IOException {
List<City> cities = (List<City>) cityService.findAll();
ByteArrayInputStream bis = GeneratePdfReport.citiesReport(cities);
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Disposition", "inline;
filename = citiesreport.pdf");
return ResponseEntity
.ok()
.headers(headers)
.contentType(MediaType.APPLICATION_PDF)
.body(new InputStreamResource(bis));
}
}
@RestController
公共类MyController{
@自动连线
ICityService城市服务;
@请求映射(
value=“/pdfreport”,
method=RequestMethod.GET,
products=MediaType.APPLICATION\u PDF\u值
)
public ResponseEntity citiesReport()引发IOException{
List cities=(List)cityService.findAll();
ByteArrayInputStream bis=GeneratePdfReport.citiesReport(城市);
HttpHeaders=新的HttpHeaders();
添加(“内容处置”、“内联”;
filename=citiesreport.pdf”);
返回响应性
.ok()
.标题(标题)
.contentType(MediaType.APPLICATION\u PDF)
.机构(新输入流资源(bis));
}
}
您可以使用apache pdfbox创建PDF。谢谢,但我知道PDF创建功能。但是需要将SpringRESTAPI转换为CamelRESTAPI