Why does the same file result in different sha256 in cid?

I’m trying to upload a file on https://web3.storage/ and save the same one on my server.
However, the cid generated on the site is different from the one generate on my server.
Below are the two cids:

bafybeihy2tzdnzzsxcrxvrybxuo4vt3jypm7wqrniujr4xahys6fbg3puq
bafybeiejk44th3cklkirm2szxrzrkqs2m25ag5wqlmonjckaflbiiph4q4

I checked them on https://cid.ipfs.io/. They have everything in common except sha256 hex.
These are the same files. After ipfs get, they came with the same sha256sum.


So why they are different? And when user tries to get one cid, can they also connect to the server ipfs add the other cid?

I’m new to ipfs. This might be a silly question.

web3.storage uses different chunking settings than the defaults in ipfs add (1MiB blocks, CIDv1, raw-leaves I think).

The CID identifies the Merkle-DAG that contains your file, and this Merkle-DAG is different so you have different CIDs.

3 Likes

Thanks.
By the way, can we get the chunk size directly from the cid and can users get the file from all the servers using one of the two different cids?

can we get the chunk size directly from the cid

No.

can users get the file from all the servers using one of the two different cids

No, in general should use the web3.storage one.

1 Like

Thanks a lot! I thought that others may get the same problem. And I successfully find the chunk size in the discord channel.

Command:

ipfs add --raw-leaves --chunker=size-1048576 --cid-version 1 example.file

By doing this can I generate the same cid with https://web3.storage/