Coming from the traditional file storage world, it's easy to get lost in how IPFS differs. This particular question is the most common one we receive and highlights the biggest difference in content-addressed file systems.
When a file or folder is pinned to IPFS, a content identifier (CID) is generated. That CID, as the name suggests, literally identifies the file by its content. If the file is changed, the resulting CID would be different than the original CID.
This is true of folders as well. When you upload and pin a folder, that root folder gets a CID. If any of the files in the folder were changed or removed, the root folder CID would be different.
So, the short answer is no, you cannot change the contents of a folder on IPFS and still retain the original CID for that folder.
How does this impact NFT projects?
We see this question often in the context of NFT projects. There are three approaches NFT projects can take:
โ
1. Upload the files and metadata as soon as a token is minted and set the token's URI for each minted NFT.
2. Upload the assets and the folder of metadata in advance and set the baseURI on your NFT contract.
3. Set a temporary baseURI on your contract, then have a reveal day where you update that baseURI and have it point to the folder of metadata files you stored on Pinata.