1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { fileToDataURL } from "https://esm.town/v/stevekrouse/fileToDataURL?v=1";
import { convertBlobToDataURL } from "https://esm.town/v/vladimyr/dataURL";
const file = new File(["testing stuff"], "test.txt", { type: "text/plain" });
const dataURL1 = await fileToDataURL(file);
const dataURL2 = await convertBlobToDataURL(file);
console.assert(dataURL1 === dataURL2);
console.log(dataURL1);
const resp = await fetch(dataURL1);
const text = await resp.text();
console.assert(resp.headers.get("content-type") === "text/plain");
console.assert(text === "testing stuff");
console.log(text);
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
April 23, 2024