Given a rather large folder, that has already been pushed to the network, and deleted locally. How would a file be added to that folder, without re-downloading the entire folder it?
You can only do it by using ipns after downloading it again with ipfs get
, which should be fast if it's still pinned to your local storage:
(1) first add (i.e. re-add) your folder to ipfs recursively: ipfs add -r /path/to/folder
. The second column of the last stdout line has the ipfs hash of the parent folder you just added. (The original files are still the same, so the hashes will be the same too.)
(2) then publish that hash: ipfs name publish /ipfs/<CURRENT_PARENTFOLDER_HASH>
. This will return your peer ID, and you can share the link as /ipns/<PEER_ID>
; repeat this step (ipfs name publish
) whenever the folder contents (and therefore the parent folder hash) changes. The ipns object will then always point to the latest version of your folder.
(3) if you plan on sharing more than one folder, you can create a new keypair for each folder you share (instead of using your lone peer id): ipfs key gen --type=rsa --size=2048 new-share-key
… and then use that key (instead of your default key) to publish (and later republish) that folder: ipfs name publish --key=new-share-key /ipfs/<CURRENT_PARENTFOLDER_HASH>
.
See also the documentation here: https://docs.ipfs.io/reference/cli/#ipfs-name-publish