Skip to main content

Upload File to IPFS

Get your file object first. If you're using server side NodeJs, you can use fs library for it like:

import fs from "fs";

// Read File
const file = fs.readFileSync(filepath);

If in case you are using React or other client side js framework, you can get your File object accordingly. Once you have your file object, upload to IPFS using:

let cid = await web3storage.uploadFile(file);
console.log('metadata cid:', cid);