Execute asset upload
Upload an asset from Orange Logic to an external service
ExecuteAssetUpload: function (_sURL, _oRequest, _fCallbackSuccess, _fCallBackFail)
Request parameter attributes
| Attribute | Type | Description | Required |
|---|---|---|---|
_sURL | string | The URL of the external service to which assets will be sent. Example: ${ExternalService.Config.BaseUrl} + /items/${itemID} + /versions + ?metadata=\ + encodedMetadata | yes |
_oRequest | object | An object containing the request configuration. See Request object properties below. | yes |
_fCallbackSuccess | function | A callback function invoked when the upload succeeds. Receives the response as its argument. | no |
_fCallBackFail | function | A callback function invoked when the upload fails. Receives the response as its argument. | no |
Request object properties
These properties are set on the _oRequest object.
| Property | Type | Description | Required |
|---|---|---|---|
Method | string | The HTTP call method (GET, POST, etc.). Refer to Mozilla's documentation for a full list of method options. | yes |
DORecordID | string | The record ID of an asset. | yes |
Format | string | The asset format. | yes |
ParameterName | string | The key of the key-value pair in which the asset is the value. For example, if the service uploading the file expects a key-value pair of "file:{fileName}", enter "file". | no |
Headers | object | HTTP headers of the API call. | no |
FileName | string | Name of the file to be streamed. Leave empty to use the title of the asset in OrangeDAM. | no |
ServiceName | string | The name of the external service the asset is being synced to. Used to prevent duplication: the upload is skipped if a record already exists for the same document and the same ServiceName. | no |
PathToExternalId | string | A JSONPath expression evaluated against the external service's response body to extract the identifier it assigned to the uploaded asset. For example, if the service responds with { "data": { "id": "abc123" } }, pass $.data.id to extract abc123. | no |
Example
The following example uploads a watermarked asset using values stored in script variables, and logs the result through the success and failure callbacks.
Utils.ExecuteAssetUpload(
"[Variables.watermarkedPath]",
{
Method: "GET",
DORecordID: "[Variables.recordId]",
Format: "[Variables.format]"
},
function (_sResp) {
Log.Warn('Executed successfully: ' + _sResp);
},
function (_sResp) {
Log.Warn('Execution failed: ' + _sResp);
}
);

