All instructions and examples shown here were performed and tested on an M1 Mac. However, the IPFS commands are the same on Linux, macOS, and Windows. You will to navigate your computer's directories from within the CLI. If you're unsure how to use the CLI, we recommend learning how before continuing with this guide.
# Install JS-IPFS
# Spawn a node
# Connect to IPFS
The JS-IPFS implementation is split into several Node.js modules. The following section shows examples of using the HTTP client to connect to IPFS. For more information on the different modules, examine the API Packages table
# Add a file
Now you can start to add files using JS-IPFS to the IPFS network.
Section changes coming soon
As the JS-IPFS implementation changes, some of these steps should be deemed conditional. Please reference the source packages (opens new window) for the latest updates.
# Retrieve a file
# Pin a file
Pinning a file will save the file data save to the local IPFS node and ensure data is not lost.
pin addmethod on the daemon, you can pin a file by running:
jsipfs pin add QmWcYcWY5vdDzBcAoLo3rYXQ2tLkjzu57vEePCvyhuwZRi
The result should be something like:
By default, objects that you retrieve over IPFS are not pinned to your node. If you wish to prevent the files from being garbage collected, you need to pin them. You will notice that the pin you just added is a recursive pin, meaning it is a directory containing other objects. Check out the pinning content to learn more about pinning.
# Remove a file
Removing a file from IPFS does not guarantee that it was completely removed from the network.
There is no way to know if someone else has made a copy of the content from when it became available on the network. This caveat is also found in regular HTTP networks, as nothing stops users from addressing content and creating a copy once it is pushed to IPFS.
Removing the content pin will remove a file from IPFS. In this section, we will remove the pinned
test.txt file we pinned earlier.