Skip to content

Variable: cdn ​

ts
const cdn: UnboundCdn;

Defined in: fluent/cdn.ts:212

The fluent mega-object: every CDN url flavor behind one import, chainable end to end.

Bind a host before building anything addressed by one. file, group and gif2video exist only on the object base returns, so forgetting is a compile error, not a broken url:

ts
cdn.file(uuid) // ✗ Property 'file' does not exist on type 'UnboundCdn'

The rest needs no host and works straight off cdn: conversion chains emit a path, a proxy chain takes its endpoint as an argument, and parse reads the base out of the url it is given.

Example ​

ts
import { cdn } from '@uploadcare/cdn-url/fluent'
import { prefixedCdnBase } from '@uploadcare/cdn-url/cdn-base'

const my = cdn.base(prefixedCdnBase('demopublickey'))
my.file(uuid).preview(800, 600).quality('smart').href
my.group(groupId).nth(1).href

// no host needed for these
cdn.video(uuid).size({ width: 720, height: 540 }).thumbs(5).path
cdn.parse(stored).kind