diff --git a/examples/_data.ts b/examples/_data.ts index b3669f778..65ce5321e 100644 --- a/examples/_data.ts +++ b/examples/_data.ts @@ -198,6 +198,11 @@ export const sidebar = [ href: "/examples/webassembly/", type: "example", }, + { + title: "Create object URL", + href: "/examples/create_object_url/", + type: "example", + }, ], }, diff --git a/examples/scripts/create_object_url.ts b/examples/scripts/create_object_url.ts new file mode 100644 index 000000000..543ebafd0 --- /dev/null +++ b/examples/scripts/create_object_url.ts @@ -0,0 +1,185 @@ +/** + * @title Generate downloadable files + * @difficulty beginner + * @tags web + * @run --allow-net + * @resource {https://docs.deno.com/api/web/~/URL.createObjectURL } Doc: Deno.createObjectURL + * @group Web Standard APIs + * + * Demonstrates using URL.createObjectURL() to create a downloadable text file from in-memory content. + */ + +// Create a basic HTML page with JavaScript that uses URL.createObjectURL() +const html = ` + +
+Creates a Blob containing text and generates a downloadable link
+Creates a Blob containing JSON data and generates a downloadable link
+Draw on the canvas above and download the result as a PNG image
+