DC 5.9 Uploading and replacing assets

Another very important part of the API is to upload new assets and/or replace existing assets.

Upload and replace both follows the same pattern

  1. Initiate the upload

  2. Upload the physical bytes

Initiate the upload

URL: /digizuitecore/legacyservice/api/asset/upload/initiate

Method: POST

Auth required: YES

Request properties

Name

Example

Description

Name

Example

Description

fileName

file.jpg

The filename of the file to be uploaded

computerName

ApiUpload

Parameter used to determine where the upload came from. This is used in automations to control what should happen with the upload

cropName

Banner

Optional parameter used for crops to populate the cropname

derivedFrom

123

Optional parameter used to link the crop the the parent asset from which it was cropped

folderId

42

Optional parameter used to determine which catalog folder the asset should go into

Example request:

 

POST https://<my-dam>/digizuitecore/legacyservice/api/asset/upload/initiate Authorization: AccessKey MII...zfg== Content-Type: application/json { "fileName": "file.jpg", "computerName": "ApiUpload" }

 

Example response:

{
"assetName": "file",
"sourceFilename": "file.jpg",
"uploadId": 12036,
"itemId": 29790,
"assetId": 11312,
"destinationId": 13,
"relativeLocation": "00.000.000/11.000/300/12/11312.jpg",
"assetType": 4,
"fileSize": 0
}

Uploading the physical bytes

This API is meant to be called a number of times until all bytes has been uploaded. The intention is to split the file bytes into one or more chunks and upload the chunks one by one.

The bytes must be sent in the request body and there parameters below are all parsed as query parameters.

URL: /digizuitecore/legacyservice/api/asset/upload/chunkupload

Method: POST

Auth required: YES

Request properties

Name

Example

Description

Name

Example

Description

uploadId

12036

Query parameter with Id from Initiate asset upload call used to link the bytes to the asset

chunkNumber

1

Query parameter with the number identifying the upload chunk

finished

true

Query parameter indicating whether all chunks are uploaded or not. True indicates that all chunks has been uploaded.

ReplacedAssetId

123

Optional query parameter used if the upload should replace another asset

MetadataOnReplaceHandling

1

Optional query parameter used alongside ReplacedAssetId to indicate if metadata should be kept or reset on replace. 0 is the default and means it is kept and 1 means it will be reset.

Example request:

POST https://<my-dam>/digizuitecore/legacyservice/api/asset/upload/uploadChunk?uploadId=12036&chunkNumber=1&finished=true Authorization: AccessKey MII...zfg== Request payload: [<Bytes>]