Open billbarni opened 1 year ago
Thank you for your feature request. Do you know if Camunda 7 accepts directories in the deployment API?
It does not accept directories "per se".
What could be done is just the "file path" to be defined during POST.
Some sample Java code:
String camundaUrl = "http://localhost:8080/engine-rest/deployment/create";
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost post = new HttpPost(camundaUrl);
MultipartEntityBuilder builder = MultipartEntityBuilder.create()
.addTextBody("deployment-name", "deployment")
.addTextBody("enable-duplicate-filtering", "false")
.addTextBody("deployment-source", "process application");
int fileCounter = 0;
for (Path path : paths) {
if (!Files.isDirectory(path)) {
builder.addBinaryBody(
String.format("data-%d", fileCounter++), // non-repeating-non-reserved-property-name
Files.readString(path).getBytes(StandardCharsets.UTF_8), // bytes
ContentType.APPLICATION_OCTET_STREAM, // content type
path.toAbsolutePath().toString() // filepath < Here in JS you would add to the front of the filename the dir/tree structure. E.g: 'somedir/scriptdir/script.js'
);
}
}
HttpEntity reqEntity = builder.build();
post.setEntity(reqEntity);
CloseableHttpResponse response = httpClient.execute(post);
HttpEntity entity = response.getEntity();
You can see that I add to the multipart the "whole" file path in it's name with the directory structure. So it's now considered inside a directory by the Camunda Engine deployment.
Foward slashes are what should be used for both Windows and Linux environments in this case, respecting the "resources" usage already using foward slash in Camunda Engine.
Thanks for the insights. I tried this out and indeed nested paths are accepted by the engine but only when separated with forward slash as you wrote. The result is:
I checked how we could potentially implement it, and the web APIs seem to be not so helpful. We can either choose files directly as it is now, or allow to choose directories only. However, thanks to Electron, the feature could be implemented via the dialog API. The implementation could be similar to one described at https://jaketrent.com/post/select-directory-in-electron/
I am moving this to backlog, but we will also gladly accept a PR.
Multi-directory selection dialog in browser is not supported. Multi-file AND multi-directory are not supported. (not supported on Windows systems, not implemented in electron). https://github.com/electron/electron/issues/16390
The user must be able to do this seamlessly...
When clicking the "+" button in the Camunda Modeler to upload a file, the user must be prompted to chose between uploading files of folders. Electron opens a dialog then with 'openDirectory' and 'multiSelections' OR 'openFile' and 'multiSelections' as per documentation: https://www.electronjs.org/docs/latest/api/dialog#dialogshowopendialogbrowserwindow-options
User should be able to deploy files AND directories
In Camunda Modelers default deployment dialog, the "Include additional files" button should open a file-search dialog that also accepts the additions of directories.
Many of my scripts HAVE to be inside directories, and depending on how they are deployed, the directory structure is lost.
Proposed solution
"Include additional files" opened dialog should not filter out directories
Alternatives considered
Camunda Engine should behave differently when deploying scripts using
deployment-resource-pattern
property, E.g:camunda.bpm.deployment-resource-pattern: file://camunda/deployment/**/*.*
Is not found via
classpath://whatever*
instruction in the BPM Script Task External Resources. But onlydeployment:///camunda/deployment/somedir/somescript.js
Camunda Engine at class
org.camunda.bpm.engine.impl.util.ResourceUtil
should have a configurable resource type:Replace this:
With something like:
Additional context
No response