![Forrest logo](/images/logo.png)
ipfs:tldr:501d9
ipfs: Add a file from local to the filesystem, pin it and print the relative hash.
$ ipfs add ${filename}
try on your machine
The command "ipfs add ${filename}" is used to add a file to the IPFS (InterPlanetary File System) network. Here's a breakdown of the command:
- "ipfs" is the command-line interface (CLI) tool for interacting with the IPFS network.
- "add" is a subcommand of the "ipfs" tool used to add content to the IPFS network.
- "${filename}" is a placeholder that represents the name of the file you want to add to IPFS. You need to replace it with the actual filename or the file path.
By running this command, you are instructing IPFS to add the specified file to the network. This process involves:
- Breaking the file into smaller chunks, called blocks.
- Creating a MerkleDag (a directed acyclic graph) by linking the blocks together.
- Generating a unique content identifier called a CID (Content Identifier), which represents the root of the MerkleDag.
- Storing the file's content and blocks in your local IPFS node's storage if it is not already present in the network.
- Distributing the blocks across the IPFS network, if they are not already available, by requesting them from other IPFS nodes or by providing them to other nodes if you already have them.
Once the file has been successfully added to IPFS, the command will display the CID for the file, which can be used to retrieve the file later on by running the appropriate IPFS commands.
This explanation was created by an AI. In most cases those are correct. But please always be careful and
never run a command you are not sure if it is safe.