Axon.ivy 7.0 - the Digital Business Platform - is out now...

I generate a temporary word document "docx" in the ivy files\session\ directory. Now I when the user click on a download link, the browser recognize the data as zip. How can I set the content type in the response?

asked 17.01.2014 at 17:53

jschori's gravatar image

accept rate: 100%

edited 18.02.2014 at 17:01

Flavio%20Sadeghi's gravatar image

Flavio Sadeghi ♦♦

The content type of the file is set automatically by Xpert.ivy by analyzing the file extension. The content type of a file extension is searched first in the cms type system. If it is not found there it is searched in the web container. And finally in a hardcoded list in Xpert.ivy.

In Xpert.ivy 5.0 the docx extension is known and the content type should be set automatically. In earlier version the docx extension is not known. You can add the following xml snipet to the webapps/ivy/WEB-INF/web.xml file so that the web container knows the extension and the content type of it:


answered 20.01.2014 at 09:40

Reto%20Weiss's gravatar image

Reto Weiss ♦♦
accept rate: 73%

You can find out the mimeType of e File in a Java Function.

    File f; // Set your File to f 
    HttpServletRequest request;
    request = (HttpServletRequest)

    String type = request.getSession().getServletContext().getMimeType(fileName)

Note: File f is a 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()
       InputStream inputStream = new FileInputStream(file);
       String fileName = file.getName();
       fileDownloaded = new DefaultStreamedContent(inputStream,
                           .getMimeType(fileName), fileName);
       return fileDownloaded;
} catch (Exception e) {
       Ivy.log().debug("Fehler in setStreamedContentFromFile : " + e.getMessage());
       fileDownloaded = null;


return fileDownloaded;

answered 21.01.2014 at 14:55

Raphael%20B%C3%BCrgin's gravatar image

Raphael Bürgin
accept rate: 55%

edited 21.01.2014 at 14:55

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 17.01.2014 at 17:53

Seen: 12,762 times

Last updated: 18.02.2014 at 17:01