With the code below I can download a JPG, but with PDF it does not work. I already tried to change the last line for this, but it also did not work.
file = new DefaultStreamedContent(stream, "application/pdf", fileName);
<p:commandButton value="Download do Edital" ajax="false" >
<p:fileDownload value="#{fileUploadBean.file}" />
</p:commandButton>
private StreamedContent file;
public void setFile(StreamedContent file) {
this.file = file;
}
public StreamedContent getFile() throws FileNotFoundException {
String caminho = "c:/tmp/iri.jpg";
String arquivo = "iri.jpg";
FileInputStream stream = new FileInputStream(caminho);
file = new DefaultStreamedContent(stream, caminho, arquivo);
return file;
}