Upload
The configuration is located in /upload/config.ion.
The configuration file itself is optional.
All properties in the configuration file are also optional.
Project config files inherit properties from tenant config files which inherit from the global defaults as given below.
See URL Connections for a detailed description of the connection configuration.
Upload configurations also support placeholder replacement in configuration strings.
Matching Connections to URLs
The upload worker will send HTTP requests to transfer the artifact of priint cloud rendering jobs to remote locations.
The project configuration contains a list of connection configurations identified by their url property. Typically, just one.
The best matching configuration is the configuration with the longest matching URL part (computed from the start of the URL).
If no matching configuration is found, the system falls back to a default configuration.
Typical Project Configuration Example
// /tenants/example.com/projects/datasheets/upload/config.ion
{
"connections": [{
"method": "POST",
"url": "https://example.com/priint-artifacts",
"authentication": {
"type": "ApiKey",
"key": "API-KEY",
"value": "8e104bcc93c9f7af5626bbfae2c0295eced7d86985b90f639e8844"
},
"use-chunked-transfer": false
}]
}
Together with a uploadUrl setting of https://example.com/priint-artifacts/{ticket} in /restapi/config.ion this configuration will lead to an HTTP Request like this:
POST /priint-artifacts/u6g3fzzv36nzswjdb6dzdiuvpy HTTP/1.1
Host: https://example.com
API-KEY: 8e104bcc93c9f7af5626bbfae2c0295eced7d86985b90f639e8844
Content-type: application/octet-stream
User-agent: priintgrid-upload
Content-Length: 456788
<Binary-PDF-Data>
There are three differences here compared to the default behavior:
- the HTTP method (POST instead of PUT)
- the API Key authentication
- the default transfer-encoding (no chunked but in one block with content-length)
Default Behavior
If the upload worker does only find a whitelisted URL in the config, then the system falls back to a default request.
Given the hypothetical renderpdf request like
POST /tenants/example.com/projects/datasheets/renderpdf
?custom=foo:bar
&foreignKey=0815
&upload=https://example.com/priint-artifacts/%7Bticket%7D
and a user "datasheet-jobs" job ticket of "u6g3fzzv36nzswjdb6dzdiuvpy"
and a basic configuration like
// /tenants/example.com/projects/datasheets/upload/config.ion
{
"connections": [{
"url": "https://example.com/"
}]}
we get the following request to the upload URL:
PUT /priint-artifacts/u6g3fzzv36nzswjdb6dzdiuvpy HTTP/1.1
Host: https://example.com
Content-type: application/json
User-agent: priintgrid-upload
Transfer-Encoding: chunked
<Binary-PDF-Data>
Response Evaluation and Parameter Export
The response of an upload is normally only checked for success (HTTP status 2xx).
In some cases, values must be extracted from a response header or body to be fed into later callback requests. This is typically a media ID generated by the server side during upload.
Responses can be evaluated, and values extracted as export parameter strings and added to the exportParams collection.
The following configuration example shows all three possible types of parameter extraction (header, JSON body, XML body). Typically, you will find only one or none. And never will XML and JSON be mixed, of course.
// /tenants/example.com/projects/datasheets/upload/config.ion
{
"connections": [{
"url": "https://example.com/",
"exportParams": [
{
"name": "myparam1",
"path": "MY_COSTUM_HEADER_NAME",
"source": "headers"
},
{
"name": "myparam2",
"source": "jsonBody",
"path": "my/jxpath/expr"
},
{
"name": "myparam3",
"source": "xmlBody",
"path": "my/xpath/expr"
}
]
}]
}
Limitations of export parameters
- The name of a parameter cannot be longer than 64 characters. Longer entries will be skipped.
- The value of a parameter cannot be longer than 2000 characters. Longer values will be truncated and end on
[...]. - The combined total length of all parameters (names and values) must not exceed 20,000 characters. This includes parameters from previous workers such as renderpdf export parameters. Entries that would exceed this length will be skipped.
Possible Sources
headers- "headers" is the default source type (so it can be omitted)
pathcontains the plain name (case-insensitive) of an HTTP response headerpathmay alternatively contain an XPath 1.0 expression to evaluate a map of key-value pairs (keys in lowercase only) (using JXPath library)
jsonBody- the response body is parsed as JSON (if possible)
pathspecifies an XPath 1.0 expression to evaluate the JSON object map or array (using JXPath library)
xmlBody- the response body is parsed into an XML document (if possible)
pathspecifies an XPath 1.0 expression to evaluate the XML object map or array (using standard JAXP). The context starts with the XML document element.
JSON
{
"my": {
"example": {
"value": [ "abc", 123 ]
}
}
}
The above expression my/example/value will return the string abc. To get the second expression you will use my/example/value[2].
XML
<root>
<my>
<example>
<value>abc</value>
<value>123</value>
</example>
</my>
</root>
The above expression my/example/value will return the first expr string abc. To get the second expression you will use my/example/value[2].
Error Handling Configuration
See Redelivery On Error.