Metadata

Metadata

Add custom metadata to your resources to better track and organize your transcoding workflow

Metadata are defined as key-value pairs and can be added to the following resources: upload, sourceand job. With these metadata you can add extra information to your resources and use it in your workflows. For example, you can add your own IDs to your sources to avoid keeping Chunkify IDs in your database or you can add a custom description to your jobs to help you find them later.

Add Metadata to a resource

We will add some extra information to a job, we will need to do it at the job creation time.

Metadata per resource is limited to 2048 bytes total.

import Chunkify from '@chunkify/chunkify';

const client = new Chunkify({
    projectAccessToken: 'My Project Access Token',
});

// Add metadata to a job
const job = await client.jobs.create({
    source_id: source.id,
    format: {
        id: 'mp4_h264',
        height: 1080,
    },
    metadata: {
        group: 'test_jobs',
    },
});

When adding metadata to an upload, it will also be added to the source created from this upload. See the Metadata on uploads and sources section for more details

Key-Value Filtering

As seen above Metadata is a key-value store, and you can use these to filter your resources. Using the same values as the example above we could filter our jobs to find the ones that have the group metadata set to test_jobs.

import Chunkify from '@chunkify/chunkify';


const client = new Chunkify({
    projectAccessToken: 'My Project Access Token',
});

// List all the jobs with the group metadata set to test_jobs
const jobs = await client.jobs.list({
    metadata: [['group:test_jobs']]
});

// jobs are paginated results, we can access the results of the first page
console.log(jobs.data);

Metadata on uploads and sources

Metadata added to an upload is automatically inherited by the source created from it. This is useful for tracking resources using IDs from your internal database. For example, if you want to keep track of which user uploaded a source, you can add their user ID from your internal database as metadata:

import Chunkify from '@chunkify/chunkify';

const client = new Chunkify({
    projectAccessToken: 'My Project Access Token',
});

// Add metadata with your internal user ID when creating an upload
const upload = await client.uploads.create({
    metadata: {
        uploaded_by: 'user_demo',
    },
});

// Once the upload is processed and a source is created,
// the source will inherit this metadata
// You can then filter sources by this user ID
const sources= await client.sources.list({
    metadata: [['uploaded_by:user_demo']],
    created: {
        sort: 'desc',
    }, 
});

console.log(sources.data)