How can I save multiple files in association with some business objects?



I'm currently wondering how I can save some files from user input and bind them to one business object. In my project, I have a business model called XXXrequest, in which supposed to be some attachments. But the default file uploader will only attach them to the process instance, is there any way I can persist the attachments and retrieve them at later processes?

1 answer

This one is the BEST answer!


To do that, create a list of 'Document' in your Bonita Process. In your form, link all your input file to the Document variable.
When you do that, on your form submission, bonita will save files in the BonitaDatabase.

If you need to save your file in a Business object, just transform your document list to your busniess model.
Document object have some method to get file name, binary content, ect.



Submitted by dongjun.yang_1417874 on Tue, 01/28/2020 - 16:05

Thanks for your reply! But I'm using 7.10 edition and there's no Document-class that corresponds to a document object. Now I get a list of documents but have no idea how I retrieve them from BonitaDatabse for later use.

Submitted by bastien.laurent... on Tue, 01/28/2020 - 16:26

'Document' class exist in 7.10 => Datas ->Documents ( when you have click on your process ).
When you have your list of document, if you want to receive them in other process that is independant of the first one, you just need to stock the document id or the document content id in a businessDataObject.
Then, use an SQL query to get all your document/documentContent id.

If you need to recreate a java File from a document content, you can use this method:


This method return a byte[] object. Then you can create a File.

Submitted by dongjun.yang_1417874 on Wed, 01/29/2020 - 17:53

It works, thanks for your kindness!