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 types of the uploaded files - the public assets are files that will be visible on your business' storefront, and the private access files will be accessible only to your tenant's employees.

In the following scenario, we are going to create public and private assets for an already existing category.

To add an asset for a category, you need to send a request to the Creating an asset endpoint with the media.asset_manage scope. In the following example, we are creating a private type of an asset.

API Reference
curl -i -X POST 
  'https://api.emporix.io/media/{tenant}/assets' 
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' 
  -H 'Content-Type: multipart/form-data' 
  -F 'file=[object Object]' 
  -F 'body=[object Object]'

Create public assets with a blob upload

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

Check out the "Asset of the BLOB type added for a CATEGORY" example:

API Reference
curl -i -X POST 
  'https://api.emporix.io/media/{tenant}/assets' 
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' 
  -H 'Content-Type: multipart/form-data' 
  -F 'file=[object Object]' 
  -F 'body=[object Object]'

Retrieve assets for a given category

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

In this example, we are going to retrieve all assets that belong to a particular category by providing a specific categoryId next to the q parameter. Send a request to the Retrieving all assets endpoint with the following scope: media.asset_read.

Provide the q parameter in the following format: q=refIds.id:z7235vn6-5b70-4b3d-7852-7f332736a45g, where z7235vn6-5b70-4b3d-7852-7f332736a45g is the category ID.

API Reference
curl -i -X GET 
'https://api.emporix.io/media/{tenant}/assets?pageNumber=1&pageSize=60&sort=name%2Cmetadata.createdAt%3Adesc&q=name%3A{name}' 
-H 'Authorization: Bearer ' 
-H 'X-Total-Count: false'

Last updated

Was this helpful?