thirdweb Storage
Best in class decentralized storage SDK for Browser and Node
Installation
Install the latest version of the SDK with either npm
or yarn
:
npm install @thirdweb-dev/storage
yarn add @thirdweb-dev/storage
Quick Start
Once you have the Thirdweb Storage SDK installed, you can use it to easily upload and download files and other data using decentralized storage systems.
Here's a simple example using the SDK to upload and download a file from IPFS:
import { ThirdwebStorage } from "@thirdweb-dev/storage";
const storage = new ThirdwebStorage();
const file = readFileSync("path/to/file.jpg");
const uri = await storage.upload(file);
const res = await storage.download(uri);
const data = await res.text();
Alternatively, we can use the SDK to upload and download metadata and JSON objects, and we can also upload multiple items at once:
const metadata = [
{
name: "NFT #1",
description: "This is my first NFT",
image: readFileSync("path/to/file.jpg"),
properties: {
coolness: 100,
},
},
{
name: "NFT #2",
description: "This is my second NFT",
image: readFileSync("path/to/file.jpg"),
properties: {
coolness: 200,
},
},
];
const uris = await storage.uploadBatch(metadata);
const metadata = await storage.downloadJSON(uris);
Learn More
You can learn more about thirdweb and the Storage SDK with the following resources: