Add upload stream example for Deno

This commit is contained in:
Roj Serbest 2021-10-15 13:14:02 +03:00
parent 0aa25b0ac4
commit d9f6eb7677
1 changed files with 12 additions and 0 deletions

View File

@ -0,0 +1,12 @@
import { readableStreamFromReader } from "https://deno.land/std@0.111.0/streams/conversion.ts";
import { client, login } from "./mod.ts";
await login();
const file = prompt("Path of the file to be uploaded:")!;
const blob = await new Response(readableStreamFromReader(await Deno.open(file))).blob();
const document = await client.cdn.upload(blob);
console.log("Uploaded successfully.");
console.log("Document ID:", document.id);