0
With the code below I can download a JPG, but with PDF does not work. I tried to change the last line for that, but it didn’t work either.
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;
}
See if it can help you, http://stackoverflow.com/questions/20265740/how-to-download-a-pdf-from-a-given-url-in-java
– Marconi
Does it not work for what reason? There is some error?
– Dherik