IPFS hash changes every time [/api/v2/ipfs/uploadFolder API endpoint]

Hi everyone,

I want to use the /api/v2/ipfs/uploadFolder endpoint multiple times, is it possible to use the same IPFS folder over and over again, because now I get a new IPFS hanh everytime i call it…

So I use the endpoint like this:

    axios.post("https://deep-index.moralis.io/api/v2/ipfs/uploadFolder",
        ipfsArrayImg,
        {
            headers: {
                "X-API-KEY": 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
                "Content-Type": "application/json",
                "accept": "application/json"
            }
        }
    ).then((res) => {
      //....
    }).catch((error) => {
        console.log(error)
    });

I also tried to use the ‘moralis/node’ library from npm.
For that I used this function:

const imgFile = new Moralis.File(paddedHex, { base64: imageData }, 'image/png');
await imgFile.saveIPFS({ useMasterKey: true });
const imgHash = imgFile.hash();

console.log(`ipfs://` + imgFile.hash());

The code works fine, but this functionality provides a unique hash (for every image) everytime and I can’t save my images under a specific folder/hash.

Can someone explain me how I can use a IPFS folder hash multiple times. Thank you.

you will have to upload all the files at once to have them with the same hash

Hi Cryptokid,

Thank you for the quick reply.

So to met the IERC1155 standard I don’t have to combine all my NFT images in one IPFS folder?

Because I just discovered this article https://moralis.io/erc1155-exploring-the-erc-1155-token-standard/ where we use our own game server to provide the correct json files.
This way I can continue to create NFTs at a later time with their own unique IPFS hash?

You don’t need to upload the images on same folder on IPFS in general for erc1155, you only need to know what is the location of the images to include them in the metadata json files