10

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.

Pat Cappelaere
  • 391
  • 1
  • 2
  • 11

4 Answers4

6

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>

Utgarda
  • 686
  • 4
  • 23
3

You can use this command to list all objects

ipfs files ls
m4n0
  • 29,823
  • 27
  • 76
  • 89
  • 1
    What's the difference between this and `ipfs filestore ls`, as others have suggested? When might this be preferred? – Jeremy Caney Oct 01 '21 at 16:07
1

If you are interested in local files added with something like ipfs add -r --nocopy /files, what you want is

ipfs filestore ls

Unfortunately now this lists blocks instead of whole files, see https://github.com/ipfs/go-ipfs/issues/5293

futpib
  • 520
  • 6
  • 15
0

you can use the command:

ipfs filestore ls
otboss
  • 621
  • 1
  • 7
  • 16