How to Convert Fileoutputstream into Mendix File Object

3
I am calling a Java action  Input parameter (File) type . somehow i got to know that convert that mendix object into File Type using  ( InputStream f = Core.getFileDocumentContent(context, yourFileDocumentObject.getMendixObject() ) Method. In the same way how to convert File into Mendix Object ( as a return type ).   This is new File created in java action      FileOutputStream output= new FileOutputStream("C:\\Users\\TT-USER\\Desktop\\Demo4.docx");   Now i want to return this output as mendix object   I hope any one can help me !
asked
1 answers
2

You need to use the storeFileDocumentContent method in the Core API to store the contents of an InputStream (not an OutputStream) into a FileDocument.


https://apidocs.rnd.mendix.com/8/runtime/com/mendix/core/Core.html#storeFileDocumentContent(com.mendix.systemwideinterfaces.core.IContext,com.mendix.systemwideinterfaces.core.IMendixObject,java.lang.String,java.io.InputStream)

You will need to have created a FileDocument object beforehand to pass into this call. You can pass this into your Java Action, or create one using the generated proxy classes. Once this has been stored, you can use the getMendixObject() method on the Mendix FileDocument object to return it from your Java Action.

Hope this helps.

 

answered