I’m using Camunda spring boot and have a BPMN process which saves an image/png file in a variable. In one of the next activities, i want to integrate this png file in an upcoming html string to output it later in a pdf file, but i can’t get the reference or value or whatever of the file variable.
What is best practice?
Here some thoughts:
Script Task - Javascript Api call
Script Task - convert variable to representable item
the content is stored as Bytestream in the workflow. The file-var is convertible to an
InputStream. I found an example on Stackoverflow which shows how to get the InputStream from the context-var
// Get the uploaded file content
Object fileData = execution.getVariable("filename");
// The following returns a FileValueImpl object with metadata
// about the uploaded file, such as the name
FileValueImpl fileMetadata = FileValueImpl)execution.getVariableLocalTyped("filename")
// Create an InputStream from the file's content
InputStream in = (ByteArrayInputStream)fileData;
To convert it to a string this should work
String result = IOUtils.toString(in, StandardCharsets.UTF_8);