How It Works

The Que platform is designed for security, scalability, and efficient processing of large media files. This guide breaks down the core components and the typical API workflow you'll follow to sign or verify an asset.

1. Initialize the Client

Configure your SDK with your API key. The SDK automatically reads the QUE_API_KEY environment variable.

import { Que } from "que-sdk";

const que = new Que({
  apiKeyAuth: process.env["QUE_API_KEY_AUTH"] ?? "",
});

2. Upload Your Asset

Upload a local file directly using the SDK. The SDK handles getting presigned URLs and uploading to S3 automatically.

// Get presigned URL for upload
const presignedResult = await que.getPresignedUrl({
  filename: "my-image.jpg",
});

// Upload file to S3 using the presigned URL
const fileBuffer = await require('fs').promises.readFile("./my-image.jpg");
const uploadResponse = await fetch(presignedResult.uploadUrl, {
  method: 'PUT',
  body: fileBuffer,
  headers: {
    'Content-Type': 'image/jpeg',
  },
});

if (!uploadResponse.ok) {
  throw new Error('Failed to upload file');
}

console.log(`Asset uploaded with key: ${presignedResult.key}`);

3. Sign the Asset

Create a signed version of your asset with a manifest containing provenance information.

const signedAsset = await que.signAsset({
  asset: {
    bucket: "your-bucket", // Replace with your actual bucket
    key: presignedResult.key,
  },
  manifestJson: JSON.stringify({
    title: "My Signed Image",
    assertions: [{
      label: "stds.schema-org.CreativeWork",
      data: {
        "@context": "https://schema.org",
        "@type": "CreativeWork",
        "author": [{ "@type": "Person", "name": "Creator" }]
      }
    }]
  })
});

4. Verify the Asset

Check the authenticity and provenance of any signed asset.

const result = await que.verifyAsset({
  asset: {
    bucket: "your-bucket", // Replace with your actual bucket
    key: signedAsset.asset.key,
  },
  includeCertificates: true,
});
const report = JSON.parse(result.report);
console.log(`Asset is trusted: ${report.summary?.isTrusted}`);

5. Download Results

Access your processed assets through the SDK.

  • For signed assets, download the new file with embedded manifest.
  • For verification results, inspect the detailed provenance report.

This workflow ensures that your application remains fast and responsive, even when working with gigabyte-sized files.