Error upload file by storeURLToFile communitycommons

0
With the help of the java action storeURLToFile we can upload a number of documents at the same time. After we have uploaded several pdf documents we try to display them using the 'documentviewer'. However, then an error occurs which states that the document is not recognized as a pdf document. When using the normal 'upload' button everything goes fine, so it appears that the storeURLTOFile action fails. How can we upload a document with the help of storeURLToFile so that the document is stored in the same way as with the upload widget?
asked
3 answers
0
  1. Did you provide a filename to the action that ends with .pdf?
  2. Are you sure the action completed normally? That is, if you use the default mendix download widget, download it to your desktop, are you able to open it?
answered
0
  1. We provided a filename to the action that ends with .pdf.
  2. It seems that the action is complete. We added an action 'Show message' at the end of the microflow, en the message shows exactly what it should. But if I try to download the document with the download widget, I get the same errors.
answered
0

Here the java content of the action storeURLToFileDocument.

// This file was generated by Mendix Business Modeler 2.5. // // WARNING: Only the following code will be retained when actions are regenerated: // - the import list // - the code between BEGIN USER CODE and END USER CODE // - the code between BEGIN EXTRA CODE and END EXTRA CODE // Other code you write will be lost the next time you deploy the project. // Special characters, e.g., é, ö, à, etc. are supported in comments.

package communitycommons.actions;

import com.mendix.systemwideinterfaces.core.UserAction; import com.mendix.systemwideinterfaces.core.IMendixObject; import communitycommons.Misc;

/** * Retrieve a document from an URL using a HTTP GET request. * - url : the URL to retrieve * - document: the document to store the data into * - filename: the filename to store it under. Only for internal use, so it can be an arbitrary filename. * * Example URL: 'http://www.mendix.com/wordpress/wp-content/themes/mendixnew/images/mendix.png' * * NOTE: For images, no thumbnail will be generated. */ public class storeURLToFileDocument extends UserAction<boolean> { private String url; private IMendixObject _document; private system.proxies.FileDocument document; private String filename;

public storeURLToFileDocument(String url, IMendixObject document, String filename)
{
    super();
    this.url = url;
    this.__document = document;
    this.filename = filename;
}

@Override
public Boolean executeAction() throws Exception
{
    this.document = __document == null ? null : system.proxies.FileDocument.initialize(this.getContext(), __document);

    // BEGIN USER CODE
    return Misc.storeURLToFileDocument(this.getContext(), url, __document, filename);
    // END USER CODE
}

/**
 * Returns a string representation of this action
 */
@Override
public String toString()
{
    return "storeURLToFileDocument";
}

// BEGIN EXTRA CODE
// END EXTRA CODE

}

answered