Read an uploaded file

In an instanciation form, I use the widget “Upload” to join an Excel file using the URL/ “…/API/formFileUpload”.
I would like to read it with a Rest API extension in order to return is content as a JSON.

I know how to read and to access a document attach in a process by calling the method “apiAccessor.getProcessAPI().getDocumentContent()” but I don’t know how to do the same in a RestAPI :

  • Should I use the filename or tempPath as input parameter to access the file ?
  • The file has no storage id
  • The case doesn’t exist yet

Bonita doesn’t provide any API to retrieve temporary files on the server, it would lead to to many security issues.

I suggest you to define your REST API extension as the URL endpoint of the file upload widget (using the property URL). Your REST API extension must be a POST method.
The content of your file will be in the body of the request, you can retrieve it using request.getReader() or request.getInputStream(), and then parse it.

Be aware that it is not recommended to perform write operations in a REST API, write operations should be performed by processes.

Hi David,

Just to be sure that I understood well your use case, you would like to upload a file with the file upload widget in a form, and before to submit the form you would like to send the content of this uploaded file to a REST API extension to parse its content ?

Adrien

Yes, it’s what I tried to do

En un formulario de instanciación, utilizo el widget “Cargar” lo que quiero es que en otra tarea pueda visuaizar ese archivo ayuda porfa estoy usando bonita 7 soy nueva