download documents from business data



I have a process and subprocess which manage pdf documents stored in business data, and I want to display these documents same way as servlet DocumentImageServlet.

A REST API extension which implements RestApiController is the best way to do this? or can I extend DocumentImageServlet in order to get documents from business data?


1 answer


You can use the case document REST API to retrieve documents. For more information see:


Submitted by smarouani on Wed, 03/07/2018 - 12:35

Thank you for you answer, but my documents informations are in database. So to use case document REST API, I should load them in process to have access?

I tried to implement a Rest api extension as following:
def String pdfResponse
context.resourceProvider.getResourceAsStream("pdf/test.pdf").withStream { InputStream s ->
pdfResponse = s.getText()

    responseBuilder.with {

but I have these errors:
Error: FDICT bit set in flate stream: 120, 63
Error: Invalid XRef stream header
Have you any idea about this?

thank you!

Submitted by joe.pappas on Wed, 03/07/2018 - 21:11

Which version of the product are you using? Community or Subscription?

Submitted by smarouani on Thu, 03/08/2018 - 14:37

I use Community version.

Submitted by joe.pappas on Tue, 03/13/2018 - 18:36

Right, I don't believe REST API Extensions are supported in Community. In any case, file reading is beyond the scope of Bonitasoft. Here is a code snippet I used to read a file on the file system in a REST API Extension using the Subscription version of Bonita. This is just straight up Java file reading code:
String fileAndPath = "C:\\temp\\attachments\\" + fileLoc
File file = new File(fileAndPath)
Path source = Paths.get(fileAndPath)
String mimeType = Files.probeContentType(source)
FileInputStream fis = new FileInputStream(file)
byte[] bytes = new byte[fis.available()]