From fc7a23a9517e9e0107b483cdb584539f4f1aa522 Mon Sep 17 00:00:00 2001 From: joevianiphoto <101300175+joevianiphoto@users.noreply.github.com> Date: Fri, 15 Apr 2022 16:53:02 -0400 Subject: [PATCH] Update mint-nftstorage-polygon.md --- docs/tutorial/mint-nftstorage-polygon.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/tutorial/mint-nftstorage-polygon.md b/docs/tutorial/mint-nftstorage-polygon.md index 8679deb..1f7ed17 100644 --- a/docs/tutorial/mint-nftstorage-polygon.md +++ b/docs/tutorial/mint-nftstorage-polygon.md @@ -176,6 +176,27 @@ Your output should look like the listing below, where `HASH` is the CID to the a Metadata stored on Filecoin/IPFS at URL: ipfs://HASH/metadata.json ``` +I wrote this to store all images from one directory into a folder +My images were numbered 1 - 5000 (.png), so I looped through and loaded them into an array +then upload them all at once, this creates one CID on Filecoin/IPFS and each image can be access by +its owen URL: ipfs://metadata/1.png + +async function storeDir() { + let images = []; + + for(let i=1; i < 5001; i++){ + images.push(new File( [await fs.promises.readFile('assets/images/' + i.toString() + '.png')], + i.toString() + '.png' , { type: 'image/png'})) + } + + const client = new NFTStorage({ token: API_KEY }) + const metadata = await client.storeDirectory(images); + + console.log( metadata) +} + + + ### Creating your NFT on Polygon #### Create the smart contract for minting