Upload an asset

Content Hub ONE uses a media management system to upload assets and make them available for use in content. This process involves the following steps:

  1. For the assets you want to upload, generate upload links either one at a time or in bulk.

  2. Use each link to upload the corresponding asset.

  3. Use the fileId of each asset to complete the upload.

  4. Use the fileId of each asset to create the media item.

Note

The base URL for uploading media assets is https://mms-upload.sitecorecloud.io. After uploading an asset, you can transform it by manipulating the URL. For a full list of fields, parameters, and technical limitations, see the data model.

Tip

An overview of how to use the Content Management API and the Media Upload API is available on the Discover Sitecore channel.

Once the media item exists in Content Hub ONE, content authors can use it in content they create.

Use this method to generate an upload link for a single asset.

Headers

The following mandatory headers are used for validation when generating an upload link:

  • x-mms-content-type is one of the allowed media types. Content Hub ONE supports a variety of media.

  • x-mms-content-length is the length in bytes of the file being uploaded. If this header is not present, validation fails.

RequestResponse
curl --location '<BASE_URL>/api/media/v1/upload/link/generate' \
--header 'x-mms-content-type: image/jpeg' \
--header 'x-mms-content-length: 1024' \
--header 'Content-Type: application/json' \
--header 'Authorization: <BEARER_TOKEN>' \
--data '{
 "filename": "bouquet-of-color.jpg"
}'
RequestResponse
{
  "responses": [
    {
      "link": "<BASE_URL>/41bbf9be-3e5a-4de9-cadc-08db20be01bc-files/b13f5b73ef7549f8927d5eb86e6506d3?se=2023-04-11T18%3a22%3a47Z&sig=YsJ2fdwK6ZzeJKgTETekAsBx%2bWYHN6334wnCr7fPF7Y%3d",
      "fileId": "b13f5b73ef7549f8927d5eb86e6506d3",
      "requestId": "image-one-id"
    },
    {
      "link": "<BASE_URL>/41bbf9be-3e5a-4de9-cadc-08db20be01bc-files/3bff648962084e09add3471d39ae9279?se=2023-04-11T18%3a22%3a47Z&sig=Z0CHxMRnFkKIpJ4EiL7jZAH1%2fEaafyV1HGbAqIp65bU%3d",
      "fileId": "3bff648962084e09add3471d39ae9279",
      "requestId": "image-two-id"
    }
  ],
  "success": true

Copy the link to use in the next stage of the workflow. You will use the fileId when you complete the upload.

Use this method to generate multiple upload links at once. Fewer API calls are made when using the bulk method because the fileIds and the URLs are generated in one call.

RequestResponse
curl --location '<BASE_URL>/api/media/v1/upload/link/generate/bulk' \
--header 'x-mms-content-type: image/jpeg' \
--header 'x-mms-content-length: 1024' \
--header 'Content-Type: application/json' \
--'Authorization: <BEARER_TOKEN>' \
--data '[
 {
  "requestId": "image-one-id",
  "filename": "blue-exploding-lines.jpg",
  "contentType": "image/jpeg",
  "contentLength": "100500"
 },
 {
  "requestId": "image-two-id",
  "filename": "bouquet-of-color.jpg",
  "contentType": "image/jpeg",
  "contentLength": "100501"
 }
]'
RequestResponse
{
  "responses": [
    {
      "link": "<BASE_URL>/41bbf9be-3e5a-4de9-cadc-08db20be01bc-files/b13f5b73ef7549f8927d5eb86e6506d3?se=2023-04-11T18%3a22%3a47Z&sig=YsJ2fdwK6ZzeJKgTETekAsBx%2bWYHN6334wnCr7fPF7Y%3d",
      "fileId": "b13f5b73ef7549f8927d5eb86e6506d3",
      "requestId": "image-one-id"
    },
    {
      "link": "<BASE_URL>/41bbf9be-3e5a-4de9-cadc-08db20be01bc-files/3bff648962084e09add3471d39ae9279?se=2023-04-11T18%3a22%3a47Z&sig=Z0CHxMRnFkKIpJ4EiL7jZAH1%2fEaafyV1HGbAqIp65bU%3d",
      "fileId": "3bff648962084e09add3471d39ae9279",
      "requestId": "image-two-id"
    }
  ],
  "success": true

Copy the link for each image to use in the next stage of the workflow. You can only upload one asset at a time. You will use the fileId when you complete the upload.

Upload the asset

Use this method to upload an asset using the generated upload link.

RequestResponse
curl --location --request PUT '<BASE_URL>/41bbf9be-3e5a-4de9-cadc-08db20be01bc-files/b5c45c02f0e942f898898b9f5de2e04c?se=2023-04-14T13%253a05%253a02Z&sig=X7YFq1lpGiZRKu3%252bZuPJ3mzM0yMVrnRftJ4T%252bd9obq8%253d' \
--header 'x-mms-content-type: image/png' \
--header 'x-mms-content-length: 1024' \
--header 'x-ms-blob-type: BlockBlob' \
--header 'Content-Type: text/plain' \
--data '@'

Complete the upload

Use this method to complete the upload of an asset using its fileId, which was obtained when the link was generated.

RequestResponse
curl --location '<BASE_URL>/api/media/v1/upload/link/complete' \
--header 'x-mms-content-type: image/jpeg' \
--header 'x-mms-content-length: 1024' \
--header 'Content-Type: application/json' \
--'Authorization: <BEARER_TOKEN>' \
--data '{
  "fileId": "b5c45c02f0e942f898898b9f5de2e04c"
}'
RequestResponse
{
  "fileId": "b5c45c02f0e942f898898b9f5de2e04c",
  "publicLink": null
}

Do you have some feedback for us?

If you have suggestions for improving this article,