[Ethereum] Getting rid of .json file extension when uploading NFT metadata to IPFS

ipfs

I have a bunch of JSON files in a directory that I'm uploading to IPFS, to be used as NFT metadata. The problem is that after I upload them, the URI to access them looks like this: ipfs://<directory_hash>/<tokenID>.json.

This is a problem because the tokenURI function in the standard ERC721 implementation simply appends the token ID to baseURI. This means each token's URI would have to look like this: ipfs://<directory_hash>/<tokenID>, without the .json file extension.

I know I could just override this function or simply edit it, but I'd rather not. Especially because I've seen other NFT projects successfully do what I'm trying to do but can't seem to figure out.

So, when uploading JSON files in a directory to IPFS, how can I prevent the .json extension from being part of the URI?

Best Answer

I would suggest simply removing the .json extension from the files and uploading them to ipfs like that. They will function all the same, but will the URIs will then resolve correctly

Related Topic