You can find out the mimeType of e File in a Java Function.
File f; // Set your File to f
HttpServletRequest request;
request = (HttpServletRequest)
FacesContext.getCurrentInstance().getExternalContext().getRequest();
String type = request.getSession().getServletContext().getMimeType(fileName)
**Note:** File f is a java.io.File you must convert the ivyFile to a javaFile
If you want to stream the File with `<p:fileDownload>` you need `org.primefaces.model.DefaultStreamedContent;`
The Final function, which you can call in a Ivy-ScriptStep, will look something like that
public StreamedContent getStreamedConentFromFile(File file){
StreamedContent fileDownloaded = null;
try {
HttpServletRequest request;
request = (HttpServletRequest) FacesContext.getCurrentInstance()
.getExternalContext().getRequest();
InputStream inputStream = new FileInputStream(file);
String fileName = file.getName();
fileDownloaded = new DefaultStreamedContent(inputStream,
request.getSession().getServletContext()
.getMimeType(fileName), fileName);
return fileDownloaded;
} catch (Exception e) {
Ivy.log().debug("Fehler in setStreamedContentFromFile : " + e.getMessage());
fileDownloaded = null;
}
file.delete();
file.deleteOnExit();
return fileDownloaded;