Set Diagram Image

Hi.

How can I upload the diagram image using rest api? I saw a topic saying I need to upload the image along with the XML, but how cna I do this?

@edgarberlinck the image is auto-generated by camunda.

Hi. I just madeit, I just need to upload the image and xml files with the same nama

Seriously? I never saw that information, where did you find that?!

Images are not uploaded. When you view the BPMN file it is rendered using bpmn.js. Hence the use of https://docs.camunda.org/manual/7.7/reference/rest/process-definition/get-diagram/ returns a image (image/png, image/gif, … )

1 Like

Hi @StephenOTT,

Can you tell me where is image file should be located?

I need to deploy a custom image for the process diagram, but can’t find how to do this.

Thanks, Conor.

Can you explain. What do you mean you need to deploy a custom image?

A custom image is just a different visualization of the Process Definition, rather than the standard BPMN model e.g. when calling process-definition/…/diagram, I want to get that custom image, using that call.

Can I include the image as part of the deployment create REST API?
Can I include it as part of the default set of process definitions that get deployed at boot time?

The alternative is just to add it as a resource on the tomcat server I suppose?

Thanks.

You could upload the image as part of the deployment and then use the Get Resource endpoint to return you the image. https://docs.camunda.org/manual/7.5/reference/rest/deployment/get-resource/

Are you trying to use the image in another application?

Seems like I am not the only person looking for this :slight_smile:

From this SVG question I can see that its possible to install it as start up time.

Question still remains for publishing via the REST API?

Yes the image is created by another app. BTW the method of bundling the image with processes.xml resources works fine.

I was able to get that image using REST API for /process-definition/{id}/diagram call.

I also tried the tried/ reviewed the deployment calls you mentioned, it doesn’t say anything about bundling the image, it also doesn’t appear to work for diagrams. I could get the BPMN, but not associated diagram.

So still wondering if there is a REST API to publish the image at the same time as the definition is published.

When you deploy your BPMN through the rest api, you can additionally add additional files to the deployment (such as images, scripts, templates, etc). So you dont use the /get diagram endpoint, you are using the get resource endpoint. Doing this has not direct relationship with the diagram. you are just getting the image you uploaded as part of the deployment. Also know that this does not have any interaction with the Cockpit or Tasklist rendering of the diagram.

1 Like

Here is how the /diagram endpoint works:
When your BPMN XML is named foo.bpmn, then you can deploy an image foo.png along with it and it will be available via the GET diagram endpoint, i.e. the image must have the same name as the BPMN XML minus the file name extension. Supported image extensionare svg, png, jpg, gif.

Hi all,

Thanks for all the feedback, but I am starting to get confused between the 2 approaches!

I would simply like to publish using /deployment/create and include both the BPMN xml and an associated image at the same time.

I can then use GET /diagram

Naming conventions aside, is this actually possible? The REST doc doesn’t make it clear how to do this.

Thanks again, Conor.

@thorben this works with rest API deployments?

Sure, for example this works fine for me:

curl -i -X POST \
-F "process=@<path to>\invoice.v1.bpmn" \
-F "image=@<path to>\invoice.v1.svg" \
http://localhost:8080/engine-rest/engine/default/deployment/create

Just make sure the file names match.

1 Like

@thorben :+1: great!

1 Like

Thanks for the feedback, much appreciated.

Conor.