How to create an IPFS folder without having original files?

If you want something a little more “hands on”, first create the following json file (I named mine dag.json):

{
	"Data": {
		"/": {
			"bytes": "CAE"
		}
	},
	"Links": [
		{
			"Hash": {
				"/": "Qmae3RedM7SNkWGsdzYzsr6svmsFdsva4WoTvYYsWhUSVz"
			},
			"Name": "file1.txt",
			"Tsize": 14
		},
		{
			"Hash": {
				"/": "QmUtkGLvPf63NwVzLPKPUYgwhn8ZYPWF6vKWN3fZ2amfJF"
			},
			"Name": "file2.txt",
			"Tsize": 14
		}
	]
}

Then add it to your node:

> ipfs dag put --store-codec=dag-pb dag.json
bafybeidtuvmy7ratlnfkuh5pkz4whjvqa3367bok43ozcm4oet2epypgwy
> ipfs cid format -v=0 bafybeidtuvmy7ratlnfkuh5pkz4whjvqa3367bok43ozcm4oet2epypgwy
QmW85q9pmby55reZb9YrcLRr5L2gHcvTFGoSmjADCbhq1w

As you can see, you end up with the same CID for the folder.
:blush:

3 Likes