Skip to main content

Custom Storage

Easily upload and fetch files from IPFS.

Upload

const sdk = useSDK();

// File upload
const files = [
fs.readFileSync("file1.png"),
fs.readFileSync("file2.png"),
]
const result = await sdk.storage.upload(files);
// uri for each uploaded file will look like something like: ipfs://<hash>/0

// JSON metadata upload
const jsonMetadata = {
name: "Name",
description: "Description",
}
const result = await sdk.storage.upload(jsonMetadata);

// Upload progress (browser only)
const result = await sdk.storage.upload(files, {
onProgress: (event: UploadProgressEvent) => {
console.log(`Downloaded ${event.progress} / ${event.total}`);
},
});

Fetch

const sdk = useSDK();

// Your IPFS hash here
const hash = "ipfs://..."
const data = await sdk.storage.fetch(hash);