How to get byte array of file document object in java action?

0
Hi, I am using a 3rd party api which need pass file as byte[]. So, i plan to get the file content of a Mendix FileDocument in java action.  and pass it. But the Mendix Core api always return a 0 size array.   i am sure the file is exists。 Please help to have a look, what is my misstake. Java: this.Parameter = __Parameter == null ? null : myfirstmodule.proxies.XXDocument.initialize(getContext(), __Parameter);         // BEGIN USER CODE         Core.getLogger("PersonSign").info("file size:"+this.Parameter.getSize());         Core.getLogger("PersonSign").info("file Name"+this.Parameter.getName());         ByteArrayOutputStream  outstream = new ByteArrayOutputStream();         this.Parameter.getContents(getContext(), outstream);         byte[] srcPdfBytes = outstream.toByteArray();         Core.getLogger("PersonSign").info("byte array length"+srcPdfBytes.length); The logging is: size:5596 file Name6.pdf byte array length:0 How to convert he file content to a byte array?  
asked
1 answers
2

You would need to use Core.getFileDocumentContent to get an InputStream that you can then use to get the byte array.
 

InputStream f = Core.getFileDocumentContent(context, source.getMendixObject());

 

answered