How can you list all file objects loaded in IPFS?

Pat Cappelaere picture Pat Cappelaere · Nov 10, 2016 · Viewed 7.1k times · Source

I can add recursively a bunch of files within IPFS with $ ipfs add -r data/

How can I get a list back of all loaded file objects [in a specific directory]? Similar to aws s3 listObjects...

The ipfs file ls command does not seem to be recursive. I understand that I can call the API a thousand times but that does not seem to be very efficient.

I must be missing something here. Thanks, Pat.

Answer

josselin chevalay picture josselin chevalay · Dec 1, 2016

IPFS is based on Merkle tree, so you can display all elements under your root resource. You can use:

  • web ui: http://localhost:8080/ipfs/<your_root_resource_hash>
  • graphmd: https://ipfs.io/ipfs/QmNZiPk974vDsPmQii3YbrMKfi12KTSNM7XMiYyiea4VYZ/example#/ipfs/QmRFTtbyEp3UaT67ByYW299Suw7HKKnWK6NJMdNFzDjYdX/graphmd/README.md
  • shell commands:
    • ipfs ls <your_root_resource_hash>
    • ipfs refs -r <your_root_resource_hash>

Docs for ipfs files ls

edit : More important, your directory name is not persisted into IPFS. You can access your resource knowing its hash, the one you get when you add it with ipfs add -r <your_dir>