Readme

Button Link

#example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/**
* @title Reading and Writing Blobs
* @description Val Town comes with blob storage built-in. It allows for storing any data: text, JSON, images
* @resource [Blob Val](https://www.val.town/v/std/blob)
*/
// The blob helper can be imported from any val.
import { blob } from "https://esm.town/v/std/blob";
// New blobs are created using setJSON.
await blob.setJSON("key", { value: 1 });
// setJSON can be used to retrieve a specific blob.
const value = blob.getJSON("key");
console.log(value);
// The lower level set and get can be used to store non-JSON or binary data.
const resp = await fetch("https://picsum.photos/600/300");
await blob.set("image", resp.body);
const image = await blob.get("image");
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 10, 2024