public FileDownloadController() {
InputStream stream = ((ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext()).getResourceAsStream("/images/optimusprime.jpg");
file = new DefaultStreamedContent(stream, "image/jpg", "downloaded_optimus.jpg");
}
In this above code we can download only jpg file. i want to download any format of file selected in UI is there any option?
You need to pass a MIME type other than
"image/jpg"to theDefaultStreamedContentconstructor. Specifically, pass the MIME type of whatever it is that you’re trying to download, or don’t pass a MIME type at all.