Hello,
I am using the 7.11.4 community version.
A task of my process launches an external script that generates a result file in a specific directory.
I would like to build a task that :
- checks if the file exists
- if yes, automatically loads it in a document.
So far, the only ways to upload a document that I have found, are either to use the UI Designer upload widget, or to create the document from an external file, at the start of the process.
Can Someone help me ?
Thank you in advance,
Thierry.
Hi Thierry,
How do you know the path of the generated file ? Is it a process parameter or variable ?
If you know the path you can create an operation on task that assign the content of the file to a Document like this:
Left operand: yourDocumentVariable
Operator: **Set Document **
Right Operand: a script returning a org.bonitasoft.engine.bpm.document.DocumentValue
with the following content:
import java.nio.file.Files
def file = new File(‘your/file/path/on/server’)
def mimeType = Files.probeContentType(file.toPath())
new DocumentValue(file.bytes, mimeType, file.name)
There is a reference article in the documentation about documents.
HTH
Romain
Hello Romain,
thank you for your answer. It works perfectly well !!
I know the path of the file, because for the moment, it is hardcoded in a process parameter.
I haven't heard about the java.nio.file.Files class before (I'm not comfortable with java), and I think it will help me a lot.
Regards,
Thierry.