I'm trying to let users download a text file from my camel application. The trouble is, is that the file contains 0 bytes (should be 435b and is in the debugger). Could someone look at the code and advise?
I'm trying to let users download a text file from my camel application. The trouble is, is that the file contains 0 bytes (should be 435b and is in the debugger). Could someone look at the code and advise?
@Component
public class CalendarRoute extends ExceptionHandlingRoutes {
@Autowired
private CalendarService calendarService;
@Override
public void configure() {
super.configure();
rest("/calendar").description("Foo calendaring")
.produces("plain/text")
.get("/").description("accepts data to create an ics file with")
.to("direct:getIcs");
from("direct:getIcs")
.process(getIcs());
}
private Processor getIcs() {
return exchange -> {
exchange.getIn().removeHeader("Content-Length");
exchange.getIn().setHeader("Content-Type", MediaType.parseMediaType("text/calendar"));
byte[] file = calendarService.generateCalendarFile();
exchange.getIn().setBody(file);
};
}
}