Just out of curiosity: Why aren’t you using the standard way via the cam-variable-name attribute?
Cheers
Sebastian
Hello Sebastian,
Thank you for your speedy reply. I got it to work with Bytes and a byte array as value and a bit of Javascript.
To give you some additional context, this is how our form looks like (all unnecessary elements removed):
Start process.png907×408 9.57 KB
The reason we think we cannot use the cam-variable-name is because we want to set some additional attributes with each file.
I also tried with type File:
for (var i = 0; i < $scope.files.length; i++) {
camForm.variableManager.createVariable({
name: 'DOCUMENT_' + i,
type: 'File',
value: $scope.files[i].file,
valueInfo: {
filename: $scope.files[i].name,
but ran into this error:
27-Jul-2016 14:29:01.431 WARNING [http-nio-8080-exec-4] org.camunda.bpm.engine.rest.exception.ExceptionHandler.toResponse java.lang.IllegalArgumentException: Provided value is not of File, InputStream or byte[] type.
at org.camunda.bpm.engine.variable.impl.type.FileValueTypeImpl.createValue(FileValueTypeImpl.java:56)
at org.camunda.bpm.engine.rest.dto.VariableValueDto.toTypedValue(VariableValueDto.java:123)
at org.camunda.bpm.engine.rest.dto.VariableValueDto.toMap(VariableValueDto.java:146)
at org.camunda.bpm.engine.rest.sub.repository.impl.ProcessDefinitionResourceImpl.submitForm(ProcessDefinitionResourceImpl.java:161)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
and it looks like the value needs to be a byte[] as with Bytes.
If would be great if we could get this to work. Less Javascript in our form, all the better!
Regards,
Casper
When using type File you have to submit the content of the file as a Base64 encoded String (source).
I assume your $scope.files[i].file is a Javascript File object. You need to get the value of the file and encode it. The link I posted earlier contains some code that does that.
The code was meant to get you started. The mentioned variable is very specific to our project, you surely are creating something completely different. You might not even have the requirement to classify documents as we do.
Start with displaying the filenames and build on that, like storing the file content in process variables.
We have done ‘multiple file uploading’ by using the below mentioned form.
It stores data to db ,but we are unable to access it.
Actually What i am looking for is that I want to display the files that had uploaded from the previous process.
I would strongly recommend to read this documentation first. It is time well invested and will make you much more productive than the shoot and miss approach you seem to be following now.
Above set of code is calling some onchange methods.(Event listners)
I have tried these set of codes to show another browse button (Browse button is showing but files are not saved in database). No event listeners are called this time.
var y = document.createElement(“input”);
y.setAttribute(“type”, “file”);
y.setAttribute(“cam-variable-name”, “filee1”);
y.setAttribute(“cam-variable-type”, “File”);
y.setAttribute(“cam-max-filesize”, “10000000”);
y.setAttribute(“class”, “ng-valid ng-valid-cam-variable-type ng-pristine”);
y.setAttribute(“ng-model”, “filee1”);
It works and we are able to download all files. But still there is no option for identifying the files with name
From the above code files are downloading as “data” named files. Actually i want to see the original file-name when downloading.
In database(in the table ACT_RU_VARIABLE), fields TEXT_ & TEXT2_ getting null values.
You are only storing the data as a BLOB. You need to store the filename, and any other information, separately e.g. like so: