Last active
April 30, 2021 01:41
-
-
Save apow2/441f3166b0da7b3310ef54ba6a9f755c to your computer and use it in GitHub Desktop.
pin to ipfs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const pinataSDK = require('@pinata/sdk'); | |
const pinata = pinataSDK(yourKey, yourKey2); | |
const fs = require('fs'); | |
function getStream(){ | |
return fs.createReadStream(PATH_TO_IMAGES+files[i]); | |
} | |
let readableStreamForFile = getStream(); | |
//pin on IPFS | |
cur_promise = await new Promise((resolve, reject) => { | |
setTimeout(() => {}, 700);}) // space out requests, as they are rate-limited | |
.then((val) => pinata.pinFileToIPFS(readableStreamForFile)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment