Skip to content

Commit 2a4dae5

Browse files
committed
[Stream] cf-cli: add cf CLI and cloudflare.config.ts to download-videos
1 parent 78771b2 commit 2a4dae5

1 file changed

Lines changed: 170 additions & 53 deletions

File tree

‎src/content/docs/stream/viewing-videos/download-videos.mdx‎

Lines changed: 170 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ sidebar:
77
products:
88
- stream
99
---
10-
import { Tabs, TabItem } from "~/components";
10+
import { CliVariant, CliVariants, TabItem, Tabs } from "~/components";
1111

1212
When you upload a video to Stream, it can be streamed using HLS/DASH. However, for certain use-cases, you may want to download the MP4 or M4A file.
1313
For cases such as offline viewing, you may want to download the MP4 file. Whereas, for downstream tasks like AI summarization, if you want to extract only the audio, downloading an M4A file may be more useful.
@@ -75,11 +75,17 @@ The response includes the download type, URL, and processing status:
7575

7676
See the full Stream [REST API and SDK reference](/api/resources/stream/) for details on using REST API from external applications, with pre-generated SDK's for external TypeScript, Python, or Go applications.
7777

78+
</TabItem>
79+
<TabItem label="Cloudflare CLI (cf)">
80+
81+
```sh
82+
cf stream videos downloads create default --identifier <VIDEO_UID>
83+
```
84+
7885
</TabItem>
7986
<TabItem label="Workers Binding API">
80-
<Tabs>
81-
<TabItem label="index.ts">
82-
```ts
87+
88+
```ts title="src/index.ts"
8389
export default {
8490
async fetch(request, env) {
8591
const videoHandle = env.STREAM.video("VIDEO_ID");
@@ -88,27 +94,52 @@ export default {
8894
},
8995
};
9096
```
91-
</TabItem>
92-
<TabItem label="wrangler.jsonc">
93-
```json
97+
98+
<CliVariants>
99+
<CliVariant cli="wrangler">
100+
101+
```jsonc title="wrangler.jsonc"
94102
{
95103
"$schema": "node_modules/wrangler/config-schema.json",
96104
"name": "<ENTER_WORKER_NAME>",
97105
"main": "src/index.ts",
98106
"upload_source_maps": true,
99-
"compatibility_date": "$today",
107+
"compatibility_date": "<COMPATIBILITY_DATE>",
100108
"observability": {
101-
"enabled": true
109+
"enabled": true,
102110
},
103111
"stream": {
104-
"binding": "STREAM"
105-
}
112+
"binding": "STREAM",
113+
},
106114
}
107115
```
108-
</TabItem>
109-
</Tabs>
110116

111-
See the full [Workers Stream binding API reference](/stream/manage-video-library/bindings/).
117+
</CliVariant>
118+
<CliVariant cli="cf">
119+
120+
```ts title="cloudflare.config.ts"
121+
import { bindings, defineConfig } from "cf/config";
122+
import * as entrypoint from "./src/index.ts" with { type: "cf-worker" };
123+
124+
export default defineConfig({
125+
worker: {
126+
name: "<ENTER_WORKER_NAME>",
127+
compatibilityDate: "<COMPATIBILITY_DATE>",
128+
entrypoint,
129+
observability: {
130+
enabled: true,
131+
},
132+
env: {
133+
STREAM: bindings.stream(),
134+
},
135+
},
136+
});
137+
```
138+
139+
</CliVariant>
140+
</CliVariants>
141+
142+
For more information, refer to the [Workers Stream binding API reference](/stream/manage-video-library/bindings/).
112143

113144
</TabItem>
114145
</Tabs>
@@ -162,11 +193,17 @@ The response includes the download type, URL, and processing status:
162193

163194
See the full Stream [REST API and SDK reference](/api/resources/stream/) for details on using REST API from external applications, with pre-generated SDK's for external TypeScript, Python, or Go applications.
164195

196+
</TabItem>
197+
<TabItem label="Cloudflare CLI (cf)">
198+
199+
```sh
200+
cf stream videos downloads create audio --identifier <VIDEO_UID>
201+
```
202+
165203
</TabItem>
166204
<TabItem label="Workers Binding API">
167-
<Tabs>
168-
<TabItem label="index.ts">
169-
```ts
205+
206+
```ts title="src/index.ts"
170207
export default {
171208
async fetch(request, env) {
172209
const videoHandle = env.STREAM.video("VIDEO_ID");
@@ -175,27 +212,52 @@ export default {
175212
},
176213
};
177214
```
178-
</TabItem>
179-
<TabItem label="wrangler.jsonc">
180-
```json
215+
216+
<CliVariants>
217+
<CliVariant cli="wrangler">
218+
219+
```jsonc title="wrangler.jsonc"
181220
{
182221
"$schema": "node_modules/wrangler/config-schema.json",
183222
"name": "<ENTER_WORKER_NAME>",
184223
"main": "src/index.ts",
185224
"upload_source_maps": true,
186-
"compatibility_date": "$today",
225+
"compatibility_date": "<COMPATIBILITY_DATE>",
187226
"observability": {
188-
"enabled": true
227+
"enabled": true,
189228
},
190229
"stream": {
191-
"binding": "STREAM"
192-
}
230+
"binding": "STREAM",
231+
},
193232
}
194233
```
195-
</TabItem>
196-
</Tabs>
197234

198-
See the full [Workers Stream binding API reference](/stream/manage-video-library/bindings/).
235+
</CliVariant>
236+
<CliVariant cli="cf">
237+
238+
```ts title="cloudflare.config.ts"
239+
import { bindings, defineConfig } from "cf/config";
240+
import * as entrypoint from "./src/index.ts" with { type: "cf-worker" };
241+
242+
export default defineConfig({
243+
worker: {
244+
name: "<ENTER_WORKER_NAME>",
245+
compatibilityDate: "<COMPATIBILITY_DATE>",
246+
entrypoint,
247+
observability: {
248+
enabled: true,
249+
},
250+
env: {
251+
STREAM: bindings.stream(),
252+
},
253+
},
254+
});
255+
```
256+
257+
</CliVariant>
258+
</CliVariants>
259+
260+
For more information, refer to the [Workers Stream binding API reference](/stream/manage-video-library/bindings/).
199261

200262
</TabItem>
201263
</Tabs>
@@ -254,9 +316,8 @@ See the full Stream [REST API and SDK reference](/api/resources/stream/) for det
254316

255317
</TabItem>
256318
<TabItem label="Workers Binding API">
257-
<Tabs>
258-
<TabItem label="index.ts">
259-
```ts
319+
320+
```ts title="src/index.ts"
260321
export default {
261322
async fetch(request, env) {
262323
const videoHandle = env.STREAM.video("VIDEO_ID");
@@ -265,27 +326,52 @@ export default {
265326
},
266327
};
267328
```
268-
</TabItem>
269-
<TabItem label="wrangler.jsonc">
270-
```json
329+
330+
<CliVariants>
331+
<CliVariant cli="wrangler">
332+
333+
```jsonc title="wrangler.jsonc"
271334
{
272335
"$schema": "node_modules/wrangler/config-schema.json",
273336
"name": "<ENTER_WORKER_NAME>",
274337
"main": "src/index.ts",
275338
"upload_source_maps": true,
276-
"compatibility_date": "$today",
339+
"compatibility_date": "<COMPATIBILITY_DATE>",
277340
"observability": {
278-
"enabled": true
341+
"enabled": true,
279342
},
280343
"stream": {
281-
"binding": "STREAM"
282-
}
344+
"binding": "STREAM",
345+
},
283346
}
284347
```
285-
</TabItem>
286-
</Tabs>
287348

288-
See the full [Workers Stream binding API reference](/stream/manage-video-library/bindings/).
349+
</CliVariant>
350+
<CliVariant cli="cf">
351+
352+
```ts title="cloudflare.config.ts"
353+
import { bindings, defineConfig } from "cf/config";
354+
import * as entrypoint from "./src/index.ts" with { type: "cf-worker" };
355+
356+
export default defineConfig({
357+
worker: {
358+
name: "<ENTER_WORKER_NAME>",
359+
compatibilityDate: "<COMPATIBILITY_DATE>",
360+
entrypoint,
361+
observability: {
362+
enabled: true,
363+
},
364+
env: {
365+
STREAM: bindings.stream(),
366+
},
367+
},
368+
});
369+
```
370+
371+
</CliVariant>
372+
</CliVariants>
373+
374+
For more information, refer to the [Workers Stream binding API reference](/stream/manage-video-library/bindings/).
289375

290376
</TabItem>
291377
</Tabs>
@@ -340,11 +426,17 @@ await client.stream.downloads.default.delete({
340426

341427
See the full Stream [REST API and SDK reference](/api/resources/stream/) for details on using REST API from external applications, with pre-generated SDK's for external TypeScript, Python, or Go applications.
342428

429+
</TabItem>
430+
<TabItem label="Cloudflare CLI (cf)">
431+
432+
```sh
433+
cf stream videos downloads delete default --identifier <VIDEO_UID>
434+
```
435+
343436
</TabItem>
344437
<TabItem label="Workers Binding API">
345-
<Tabs>
346-
<TabItem label="index.ts">
347-
```ts
438+
439+
```ts title="src/index.ts"
348440
export default {
349441
async fetch(request, env) {
350442
const videoHandle = env.STREAM.video("VIDEO_ID");
@@ -353,27 +445,52 @@ export default {
353445
},
354446
};
355447
```
356-
</TabItem>
357-
<TabItem label="wrangler.jsonc">
358-
```json
448+
449+
<CliVariants>
450+
<CliVariant cli="wrangler">
451+
452+
```jsonc title="wrangler.jsonc"
359453
{
360454
"$schema": "node_modules/wrangler/config-schema.json",
361455
"name": "<ENTER_WORKER_NAME>",
362456
"main": "src/index.ts",
363457
"upload_source_maps": true,
364-
"compatibility_date": "$today",
458+
"compatibility_date": "<COMPATIBILITY_DATE>",
365459
"observability": {
366-
"enabled": true
460+
"enabled": true,
367461
},
368462
"stream": {
369-
"binding": "STREAM"
370-
}
463+
"binding": "STREAM",
464+
},
371465
}
372466
```
373-
</TabItem>
374-
</Tabs>
375467

376-
See the full [Workers Stream binding API reference](/stream/manage-video-library/bindings/).
468+
</CliVariant>
469+
<CliVariant cli="cf">
470+
471+
```ts title="cloudflare.config.ts"
472+
import { bindings, defineConfig } from "cf/config";
473+
import * as entrypoint from "./src/index.ts" with { type: "cf-worker" };
474+
475+
export default defineConfig({
476+
worker: {
477+
name: "<ENTER_WORKER_NAME>",
478+
compatibilityDate: "<COMPATIBILITY_DATE>",
479+
entrypoint,
480+
observability: {
481+
enabled: true,
482+
},
483+
env: {
484+
STREAM: bindings.stream(),
485+
},
486+
},
487+
});
488+
```
489+
490+
</CliVariant>
491+
</CliVariants>
492+
493+
For more information, refer to the [Workers Stream binding API reference](/stream/manage-video-library/bindings/).
377494

378495
</TabItem>
379496
</Tabs>

0 commit comments

Comments
 (0)