Adds an IPFS object to the pinset and also stores it to the IPFS repo. pinset is the set of hashes currently pinned (not gc'able).
Where:
hash
is an IPFS multihash.options
is an object that can contain the following keys- 'recursive' - Recursively pin the object linked. Type: bool. Default:
true
- 'recursive' - Recursively pin the object linked. Type: bool. Default:
callback
must follow function (err, res) {}
signature, where err
is an error if the operation was not successful. res
is an array of objects that represent the files that were pinned. Example:
{
hash: 'QmHash'
}
If no callback
is passed, a promise is returned.
Example:
ipfs.pin.add(hash, function (err) {})
List all the objects pinned to local storage or under a specific hash.
Where:
hash
is an IPFS multihash.options
is an object that can contain the following keys:- 'type' - Return also the type of pin (direct, indirect or recursive)
callback
must follow function (err, pinset) {}
signature, where err
is an error if the operation was not successful. pinset
is an array of objects with keys hash
and type
.
If no callback
is passed, a promise is returned.
Example:
ipfs.pin.ls(function (err, pinset) {
if (err) {
throw err
}
console.log(pinset)
})
A great source of examples can be found in the tests for this API.
Remove a hash from the pinset
Where:
hash
is a multihash.options
is an object that can contain the following keys- 'recursive' - Recursively unpin the object linked. Type: bool. Default:
true
- 'recursive' - Recursively unpin the object linked. Type: bool. Default:
callback
must follow function (err) {}
signature, where err
is an error if the operation was not successful.
If no callback
is passed, a promise is returned.
Example:
ipfs.pin.rm(hash, function (err, pinset) {
if (err) {
throw err
}
console.log(pinset) prints the hashes that were unpinned
})
A great source of examples can be found in the tests for this API.