I have a filedownload that doesn't work as wanted. I followed the instructions provided in this thread, but the file that gets downloaded is just a file with the name null but of the size of the file i wanted to download originally. The command i use is
<p:commandLink ajax="false">
Download
<p:fileDownload value="#{dtEditView.file}"/>
</p:commandLink>
My bean consists of the following
public StreamedContent getFile() throws IOException {
path = "C:\\test.jpeg";
contentType = FacesContext.getCurrentInstance().getExternalContext().getMimeType(path);
return new DefaultStreamedContent(new FileInputStream(path), contentType);
}
What am i doing wrong and what am i missing? I am using Primefaces 5.2.
Edit: I renamed the file into the file extension it is supposed to be and it appears to be what i wanted. The remaining questions are still?
- Why is it renamed to null?
- How can i set the correct file extension in an automatical manner?