Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Media Tutorial

You can upload or link to media files and other documents by using the Emporix Media Service. The files can be associated with specific resources within the Emporix database, or remain unassigned.

It is possible to assign assets to BRAND, CATEGORY, LABEL, PRODUCT, MODULE, AGENT, or any custom schema type. To associate an asset with a predefined resource type such as CATEGORY or PRODUCT, set access to PUBLIC. Private assets can be linked to AGENT, custom schema types, or remain unassigned.

How to manage public and internal assets

The assets can either be linked to an external website where they are stored, or uploaded in the form of blob data by using a multipart/form-data request.

You can also specify the access type of each asset:

  • PUBLIC – Stored on public storage and accessible from an external URL. Use this access type for storefront-visible media, such as category banners or product images.

  • PRIVATE – Stored on private storage and accessible through an authenticated download request or a temporary signed URL. Use this access type for internal documents, such as contracts or specification sheets.

Classic multipart uploads remain available as a compatibility alternative. In this flow, file bytes pass through the Media API. Classic downloads also remain available, but they stream through the Media API and therefore stay slower than a direct download. The classic download also applies the configurable 30 MB default streaming limit described in Classic download compatibility.

How to upload assets directly to storage

Direct upload lets your application send file bytes to the storage provider instead of through the Media API. Private blobs are stored in Google Cloud Storage (GCS), while public blobs are stored in Cloudinary.

Direct uploads are not subject to the 30 MB classic multipart request limit because the file bytes go directly to storage.

Use a service OAuth2 token with the media.asset_manage scope to create upload sessions.

An upload session creates an asset with the PENDING status and returns short-lived storage instructions. Follow one of these provider-specific flows:

  • Private GCS signed PUT – omit uploadType or set it to put.

  • Private GCS multipart POST – set uploadType to form.

  • Public Cloudinary multipart POST – set access to PUBLIC. Cloudinary uses a form regardless of uploadType.

Upload a private asset with a signed PUT

1

Start the upload session

Start an upload session by sending an application/json request to the Starting an upload session endpoint.

API Reference

The response contains the pending asset ID and the exact storage request to send:

2

Upload the file to GCS

Send the file to the returned upload.url without an Emporix access token. Copy every returned header unchanged.

GCS signed upload credentials are valid for 15 minutes by default. The upload session itself expires after one hour by default.

3

Wait for the asset to become ready

Follow the Wait for the uploaded asset procedure with the returned asset ID.

Upload a private asset with a multipart form

1

Start the form upload session

Set uploadType to form to receive a signed GCS POST policy.

A representative response is:

2

Submit the multipart form

Submit every field returned in upload.fields unchanged. Append the file part last. GCS form instructions do not include x-goog-if-generation-match.

3

Wait for the asset to become ready

Follow the Wait for the uploaded asset procedure with the returned asset ID.

Upload a public asset to Cloudinary

1

Start the public upload session

Create a session with access set to PUBLIC. Public blobs are stored in Cloudinary and always use a multipart POST.

A representative response is:

2

Submit the Cloudinary form

The api_key is expected public form data. The Cloudinary API secret is never returned. Cloudinary form instructions are valid for one hour. Submit every returned field unchanged and append the file part last.

3

Wait for the asset to become ready

Follow the Wait for the uploaded asset procedure with the returned asset ID.

Wait for the uploaded asset

Storage confirmation is asynchronous. After a successful storage upload, retrieve the asset with the Retrieving an asset endpoint and check whether status is READY. If the status is PENDING, completion is still in progress, although the response can already contain asset fields. Use a service OAuth2 token with the media.asset_read scope.

While completion is pending, the response can contain:

Retrieve the asset again while its status is PENDING. When completion finishes, the response contains status: READY:

If a storage notification is delayed, retrieving the asset or scheduled cleanup can detect the stored file and complete the asset. The service emits the media.asset-created event only after it confirms that the file is stored and changes the asset status to READY. Operations that need the stored file return 409 while it is unavailable:

Unused upload sessions expire after one hour by default. Cleanup removes an expired pending asset if no uploaded file exists.

How to download assets directly from storage

Use Retrieving a download URL as the default method for downloading assets. Direct download is always faster than streaming the file through the Media API, because the client fetches the file from storage. Use a service OAuth2 token that has the media.asset_read scope. This endpoint is available regardless of whether direct upload is enabled.

1

Request a download URL

For a private GCS blob, omit disposition to use the default value, attachment.

The response contains a signed GCS URL that is valid for 15 minutes by default:

Set disposition=inline to request a signed private GCS URL suitable for inline display.

The disposition parameter affects private GCS signed links only. Omit it for attachment, or set it to inline. An empty or unsupported value returns 400 with disposition must be inline or attachment. The parameter does not change public Cloudinary URLs or stored LINK URLs.

For a public blob, the endpoint returns its permanent Cloudinary URL. It does not return expiresAt.

2

Retrieve the file from storage

Use the returned URL directly. Do not send the Emporix access token to GCS or Cloudinary.

For a private GCS URL:

For a permanent public Cloudinary URL:

Classic download compatibility

The classic GET /media/{tenant}/assets/{assetId}/download endpoint remains available as a compatibility alternative. It streams file content through the Media API, so it is slower than a direct download.

When the known details.bytes value exceeds the configurable default of 31,457,280 bytes (30 MB), the classic endpoint returns 413. Assets without a known byte count are not rejected by this check. The direct-download endpoint has no corresponding file-size gate.

How to associate a public asset with a resource

To link media to a category, product, or other predefined resource type, create the asset with "access": "PUBLIC" and provide the target in refIds. Requests that combine PRIVATE access with predefined refIds types (such as CATEGORY or PRODUCT) are rejected with a 400 response.

After association, you can manage the asset in the Management Dashboard from the related resource view (for example, a category or product).

To add a linked asset for a category, or other resource, send an application/json request to the Creating an asset endpoint with the media.asset_manage scope.

In this example, create a PUBLIC LINK asset and associate it with a category.

API Reference

Upload a public asset as a blob

You can create a public asset for a category, or other resource, for example an image, by uploading the file and its metadata. Send a multipart/form-data request to the Creating an asset endpoint with the media.asset_manage scope.

API Reference

How to create a private internal asset

Private assets are intended for tenant-internal use and are not exposed on the storefront. Typical use cases include supplier contracts, technical specification sheets, or compliance documents that your employees need to access from the Management Dashboard or through the API.

Create a private asset without refIds, or associate it with AGENT or a custom schema type in refIds. Private assets cannot be linked to predefined types such as CATEGORY or PRODUCT. After creation, retrieve the file through the Downloading an asset endpoint with the media.asset_read scope.

Upload an unassociated private asset

In this example, upload an internal contract as an unassociated PRIVATE BLOB asset.

API Reference

Associate a private asset with a custom schema type

If you model business objects with the Schema Service, you can attach private files to a custom instance. Set refIds.type to your custom schema type ID (for example, DOCUMENT) and refIds.id to the custom instance ID.

In this example, attach a signed agreement PDF to a DOCUMENT custom instance as a PRIVATE BLOB asset.

API Reference

How to retrieve assets for a given category

By providing query values, you can retrieve assets that fulfil specific criteria.

In this example, retrieve all assets that belong to a particular category by providing the category ID in the q parameter. Send a request to the Retrieving all assets endpoint with the media.asset_read scope.

Provide the q parameter in the following format: q=refIds.id:123e06ecf0452c2d6c0b81392, where 123e06ecf0452c2d6c0b81392 is the category ID.

API Reference

How to clean up uploaded assets

Delete assets that were created only for a temporary workflow by calling the Deleting an asset endpoint with the media.asset_manage scope.

A successful deletion returns 204 No Content.

Last updated

Was this helpful?