Docs
Home
  • 🎉Welcome
    • Intro
    • Installation
  • 💾SDK
    • Upload
    • Download
    • Tokens (Client upload)
    • Publish
    • List and Search
    • Delete
  • 🚲Examples
    • File upload component (Next.js)
    • Download button (Next.js)
Powered by GitBook
On this page
  1. SDK

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" });
PreviousInstallationNextDownload

Last updated 6 months ago

💾