I have an InputStream from another server (PDF file from JasperReports) and user is able to download it.
...
VerticalLayout content;
OperationResult<InputStream> jresult;
...
final InputStream ent=jresult.getEntity();
if (ent.available()<=0) return;
Link link = new Link();
link.setCaption("Download the report");
link.setResource(new StreamResource(new StreamSource(){
private static final long serialVersionUID = 1L;
@Override
public InputStream getStream() {
return ent;
}
}, "FileName.pdf"));
content.addComponent(link);
If the print server returns the page, "Download the report" will appear and the user can download PDF file by click. But second click on the same link fails. It probably returns empty content. What is wrong? Maybe I must rewind the input stream. How?