Configure the process
To send a file to a process you need to, do the following:
- Enable sub-process mode in the process and set Access level to
Public
.
- Create a file data (such as
REQUEST_FILE
) and selectIN
orINOUT
as sub-process parameters.
- Create an Incoming webhook type application.
Create a request with a file as parameter
With webhooks, you need to use the createRequest
method. There are three ways to send a file:
-
Send a file URL
-
Send a base64 file
-
Send an uploaded file
Send a file URL
The file you want to upload needs to be accessible by WorkflowGen. You can set a physical path in the URL that will be accessible by WorkflowGen (prefixed by file:///
), or use another URL.
Local file
{
"operation": "createRequest",
"args": {
"input": {
"processName": "SIMPLE_REQUEST_FILE",
"processVersion": 1,
"parameters": [{
"name": "REQUEST_FILE",
"fileValue": {
"name": "test.txt",
"contentType": "text/plain",
"size": 616,
"url": "file:///C:/Hooks/test.txt"
}
}]
}
}
}
To authorize WorkflowGen to access your file, go to the Configuration Panel Integration tab. In the Webhooks section, enter your folder path in the Input file allowed folders (comma separated values) field.
Public file
{
"operation": "createRequest",
"args": {
"input": {
"processName": "SIMPLE_REQUEST_FILE",
"processVersion": 1,
"parameters": [{
"name": "REQUEST_FILE",
"fileValue": {
"name": "test.txt",
"contentType": "text/plain",
"size": 4120858,
"url": "http://download.workflowgen.com/product/latest/update.zip"
}
}]
}
}
}
Use file content parameter
{
"operation": "createRequest",
"args": {
"input": {
"processName": "SIMPLE_REQUEST_FILE",
"processVersion": 1,
"parameters": [{
"name": "REQUEST_FILE",
"fileValue": {
"name": "test.txt",
"contentType": "text/plain",
"size": 12,
"content":"SG9va3MgRmlsZQ=="
}
}]
}
}
}
To authorize WorkflowGen to rebuild the file, go to the Configuration Panel Integration tab. In the Webhooks section, set the size in the Maximum input file content size (kB) field.
Use an uploaded file
curl -X POST \
http://localhost/wfgen/hooks/HOOKSTOKEN \
-H 'content-type: multipart/form-data' \
-F 'payload={"operation": "createRequest", "args": { "input": {"processName": "SIMPLE_REQUEST_FILE", "processVersion": 1, "parameters": [ { "name": "REQUEST_FILE", "fileValue": {"uploadMap":"z_file1" }}] } } }' \
-F 'z_file1=@C:\Hooks\test.txt'
Input.parameters[X].fileValue
should contain an uploadMap
whose value is the (\"fileValue\": {\"uploadMap\":\"z_file1\" })
key of the file to be uploaded.
You can add more than one file.
Test
You can use the postman project to test.