Import from a third party
Download an asset from a third-party application by providing a download URL and a target folder. You can also indicate asset metadata to save and specify retry mechanisms. Each attribute is defined in the table below.
ImportFromThirdParty: function (_oOptions, _fCallbackSuccess, _fCallBackFail)
+ _oOptions.DownloadUrl:
+ _oOptions.FolderID:
+ _oOptions.Headers:
+ _oOptions.SingleValueMetadata:
+ _oOptions.MultiValueMetadata:
+ _oOptions.ExternalID:
+ _oOptions.ExternalService:
+ _oOptions.SaveToFileName:
+ _oOptions.ForcedSubType:
+ _oOptions.DownloadRetries:
+ _oOptions.DownloadMinWaitBeforeRetry:
+ _oOptions.DownloadMaxWaitBeforeRetry:
+ _oOptions.ImportRetries:
+ _oOptions.ImportMinWaitBeforeRetry:
+ _oOptions.ImportMaxWaitBeforeRetry:
Request parameter
The Options
object uses the following attributes:
Attribute | Type | Description | Default value | Required |
---|---|---|---|---|
DownloadUrl | string | The download URL of the asset to import. | undefined | yes |
FolderID | string | The record ID of the folder the asset will be imported to. | undefined | yes |
Headers | object | HTTP headers of the API call. | undefined | no |
SingleValueMetadata | object | API names of single-value metadata fields. Values in this object are strings. | undefined | no |
MultiValueMetadata | object | API names of multivalued metadata fields. Values in this object are arrays of strings. | undefined | no |
ExternalID | string | The ID of the asset in the third-party application. | undefined | no |
ExternalService | string | The name of the third-party application. | undefined | no |
SaveToFileName | string | The filename of the asset in the third-party application. This data is stored in the OriginalFileName field in Orange Logic. | undefined | no |
ForcedSubType | string | The asset subtype to apply to the imported asset. When this attribute is undefined, Orange Logic applies the standard subtype based on the file type. For example, the Standard Image subtype is applied to image files. | undefined | no |
DownloadRetries | number | The number of download retry attempts. | 3 | no |
DownloadMinWaitBeforeRetry | number | The minimum number of minutes to wait before a download retry. | 100 | no |
DownloadMaxWaitBeforeRetry | number | The maximum number of minutes to wait before a download retry. | 1000 | no |
ImportRetries | number | The number of import retry attempts. | 3 | no |
ImportMinWaitBeforeRetry | number | The minimum number of minutes to wait before an import retry. | 100 | no |
ImportMaxWaitBeforeRetry | number | The maximum number of minutes to wait before an import retry. | 1000 | no |
Example
Utils.ImportFromThirdParty(
{
DownloadUrl: `https://mangovations.orangelogic.com/AssetLink/4ry6b3133j753w1a03nh3t8jpwspyx17.JPG`,
FolderID: '2Y8TWAFUPL3',
Headers: {
'Authorization': `Bearer ABCXYZ123456`,
},
SingleValueMetadata: {
"CoreField.Title": "Imported through call external API",
"TestNameSpace.TestField": "Test value"
},
MultiValueMetadata: {
"CoreField.Keywords": ["Keyword1", "Keyword2"]
},
ExternalID: "External123",
SaveToFileName: `newfilename.jpg`,
ExternalService: "OrangeDAM"
},
// Success callback function
function (_sResp) {
Log.Info('Downloaded and imported successfully: ' + _sResp);
},
// Failure callback function
function (_sResp) {
Log.Warn('Failed to import: ' + _sResp);
}
);
Updated 13 days ago