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.
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.
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– omituploadTypeor set it toput.Private GCS multipart
POST– setuploadTypetoform.Public Cloudinary multipart
POST– setaccesstoPUBLIC. Cloudinary uses a form regardless ofuploadType.
Upload a private asset with a signed PUT
Start the upload session
Start an upload session by sending an application/json request to the Starting an upload session endpoint.
The response contains the pending asset ID and the exact storage request to send:
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
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
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.
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.
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).
Associate a public asset by link
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.
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.
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.
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.
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.
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?

