Upload

Uploading a file is as simple as calling the `set` method with the file name and the file content.

import fs from "fs";
import { f0 } from "file0";

// Upload a json object
await f0.set("hello.json", JSON.stringify(myBigObject));

// Upload a text file from the file system
await f0.set("logs.txt", fs.readFileSync("./logs.txt"));

// Upload a blob
await f0.set("image.png", new Blob());

// Upload a public file
await f0.set("image.png", myFile, { public: true });

// Upload a file with expiration
await f0.set("image.png", myFile, { ttl: "30d" });

Last updated