Skip to content

Instantly share code, notes, and snippets.

@apow2
Last active April 30, 2021 01:41
Show Gist options
  • Save apow2/441f3166b0da7b3310ef54ba6a9f755c to your computer and use it in GitHub Desktop.
Save apow2/441f3166b0da7b3310ef54ba6a9f755c to your computer and use it in GitHub Desktop.
pin to ipfs
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