publish.ts
1 import { IPFSHTTPClient } from "kubo-rpc-client/types"; 2 3 export async function publish(ipfs: IPFSHTTPClient, path: string, key: string | undefined) { 4 const res = await ipfs.files.stat(path); 5 6 console.log(`${path} => ${res.cid.toString()}`); 7 console.log(`Publishing to key ${key}`); 8 9 await ipfs.name.publish(res.cid, { 10 key: key, 11 }); 12 13 console.log('Done!'); 14 }