docs
  1. SCAYLE Resource Center
  2. Developer Guides
  3. Customise & Extend
  4. Manage Generic Assets

Manage Generic Assets

General

You can add assets to the SCAYLE Content Delivery Network (CDN) in two ways: by uploading files from your local system or by providing URLs of existing images. Assets can be uploaded as base64 encoded attachments or by specifying the URL of a self-hosted image.

These assets do not have a product relation. If this is needed, please refer to product assets.

Access your CDN by calling https://{{tenant-space}}.cdn.scayle.cloud.

For example, if your tenant is "acme" and the space is "live," the CDN URL would be: https://acme-live.cdn.scayle.cloud.

Supported asset file types

The Admin API supports the following file formats:

  • JPEG (for high-quality images)
  • PNG (for images with transparency)
  • GIF
  • PDF

Asset Entity

ParameterDetails
source

AssetSource

A source from where to upload an asset.

Asset URL entity

ParameterDetails
assetUrl

String

URL of the image, generated by SCAYLE.

Admin API

Create an asset

Learn how to create assets with different sources.

This method can be used to create a new asset by either passing an attachment or by providing the URL of an existing image.

You either have to provide attachment or URL depending on your use case.

const response = await adminApi.apis.Assets.createAsset({requestBody: newAsset});
const createdAsset = response.body;

Details

When creating a new asset, it will be uploaded to the SCAYLE CDN.

The generic create endpoint returns the hash of the uploaded assets. Ensure you store this generated hash on your end, as there are no List or Delete endpoints available for assets.

Uploading Assets

When uploading an asset to the CDN, you have to provide an asset source in the source property.

You can either specify a URL or a base64-encoded string containing valid binary image data.

Asset

ParameterDetails
source

AssetSource

A source from where to upload an asset.

Asset Source

ParameterDetails
url

String

URL of remote asset.

attachment

String

Base64-encoded binary asset data.

Asset URL

ParameterDetails
assetUrl

String

URL of the image or PDF file, generated by SCAYLE.

Examples

Upload an Image from a Source URL

let newAsset = {
    source: {
        url: "https://example.com/myImage.jpg"
    }
};

let response = await adminApi.apis.Assets.createAsset({requestBody: newAsset});
let createdAsset = response.body;

Upload an Image from a Local File

let newAsset = {
    source: {
        attachment: fs.readFileSync('images/myImage.jpg').toString('base64')
    }
};

let response = await adminApi.apis.Assets.createAsset({requestBody: newAsset});
let createdAsset = response.body;