Cant retrieve filedocument content in custom java action

0
I have an entity that inherits the “FileDocument” class called “TestFile” and I want to get the binary content of the file inside some custom Java for later manipulation.   I created a custom java action that takes a List of TestFiles and loops through each one. if I try to access any attribute of the TestFile, it works fine, but I can’t seem to figure out how to access the binary content.  My executeAction function is below:  public java.lang.String executeAction() throws Exception { this.Parameter = new java.util.ArrayList<myfirstmodule.proxies.TestFile>(); if (__Parameter != null) for (IMendixObject __ParameterElement : __Parameter) this.Parameter.add(myfirstmodule.proxies.TestFile.initialize(getContext(), __ParameterElement)); // BEGIN USER CODE int length = this.Parameter.size(); String bla = ""; for (int a = 0;a < length;a++) { InputStream inputStream; TestFile myobject = this.Parameter.get(a); inputStream = Core.getFileDocumentContent(getContext(), myobject); //bla = myobject.getTestStringField(); -THIS WORKS FINE } return bla; // END USER CODE } I get an error on the getFileDocumentContent method : “The method getFileDocumentContent(IContext, IMendixObject) in the type Core is not applicable for the arguments (IContext, TestFile)” I’m not sure exactly what I’m supposed to put as that second object. I figured each __ParameterElement” in “this” was an IMendixObject and each “TestFile” should be one of these parameters. What am I missing?
asked
2 answers
1

You need to use the getMendixObject() method from the TestFile proxy. 
 

inputStream = Core.getFileDocumentContent(getContext(), myobject.getMendixObject());


Hope this helps.

answered
0

Answering my own question after playing around.

 

Instead of

inputStream = Core.getFileDocumentContent(getContext(), myobject);

 

I did this.

inputStream = Core.getFileDocumentContent(getContext(), __Parameter.get(a));

 

Seems weird since technically they should be the same thing, but it worked.  

answered