How to download a PDF that is in C: \

0

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;
    }
    
asked by anonymous 24.11.2015 / 14:33

1 answer

1
 public StreamedContent getFile() throws FileNotFoundException {

    String arquivo = "iri.jpg";

    String caminho = "C:\tmp\"+arquivo;

    FileInputStream stream = new FileInputStream(caminho);      
    file = new DefaultStreamedContent(stream, caminho, arquivo);  

  return file;
}
    
26.11.2015 / 18:47