ipfs storage
// store.mjs
2
3 import { Web3Storage, getFilesFromPath } from 'web3.storage'
4
5 const token = process.env.API_TOKEN
6 const client = new Web3Storage({ token })
7
8 async function storeFiles () {
9 const files = await getFilesFromPath('/path/to/file')
10 const cid = await client.put(files)
11 console.log(cid)
12 }
13
14 storeFiles()
|
Copied!
Run it with
npm i web3.storage
API_TOKEN=YOUR_TOKEN node ./store.mjs