Uploading Files

You can add any type of content to IPFS. In this case we will put some text content into a .txt file called mytextfile.txt and put the text IPFS TEST - VERSION 1 in it.

echo "IPFS TEST - VERSION 1" > mytextfile.txt

You can read the file's contents using the cat command:

cat mytextfile.txt
IPFS TEST - VERSION 1
ipfs add mytextfile.txt
added QmS7S76K81Qq5AeHFN5tPL8uDhY3NCCSSSBAD4xaMAq87m mytextfile.txt

Save the hash that IPFS returned. This is the content's cryptographic hash. If the file's content changes, the hash will change, but if the file's content remains the same, the hash will always be the same.

Downloading files from IPFS

You can now try to download the file you've just uploaded to IPFS

ipfs cat QmS7S76K81Qq5AeHFN5tPL8uDhY3NCCSSSBAD4xaMAq87m
IPFS TEST - VERSION 1

How IPFS identifies files

IPFS tracks content based on its cryptographic hash. This hash uniquely identifies exactly that content. As long as the content stays the same, the hash stays the same, but if the content changes at all you will get a different hash. If you have two different files that contain identical content, IPFS will track that content with one hash. The filenames are different, but the content is the same, so the hash of the content will be identical.