Correct way to pin a directory via IPFS API

Hi, I have a question regarding how pinning works with regard to directories. I’m using the object_put endpoint to create a directory (DAG node), connected to some previously uploaded files.

My question is: Does setting the pin option to true on the object_put request mean the connected files will also be pinned? Or does this apply only to the new object?

Thanks!

1 Like

hi @pichiste, as far as I know it only pins the new object, this looks to be also stated in the ipfs api spec Command-line reference | IPFS Docs

1 Like

Thanks for the reply @traian.vila. What would be the correct way then to pin that directory and everything it contains? Would a single call to pin_add with the hash of the newly created “directory” object do the trick? Or does each thing inside the directory need to be pinned individually?

1 Like

According to this, it should default to “recursive” and therefore pin everything connected to it?
https://docs.ipfs.io/reference/cli/#ipfs-pin-add

1 Like