Upload a Directory
Upload multiple files as an IPFS directory and get the root CID that addresses the whole structure.
Upload the directory
import { Pinner } from "@lumeweb/pinner";
const pinner = new Pinner({ jwt: process.env.PINNER_AUTH_TOKEN! });
const files = [
new File(["Hello, IPFS!"], "hello.txt", { type: "text/plain" }),
new File(['{"name": "config"}'], "config.json", {
type: "application/json",
}),
];
const operation = await pinner.uploadDirectory(files);
const result = await operation.result;
console.log("Root CID:", result.cid);# Upload an entire directory
pinner upload ./my-directory/
# The root CID, gateway URL, size, and duration are printed to the terminalWhat is the root CID?
When you upload a directory, IPFS creates a tree of CIDs: one for each file, plus intermediate nodes. The root CID addresses the top of that tree. With the root CID alone you can reach every file inside the directory.
Verify the upload
You can check that the content is reachable through a public gateway:
https://<ROOT_CID>.ipfs.inbrowser.link/hello.txt
Or check the pin status:
const pinInfo = await pinner.pins.get(result.cid);
console.log(pinInfo.status);pinner status <CID>