How to list all the file using go shell ipfs

Hi all,

i have a go lang project which using go shell ipfs library.
shell “

may i know how i can list all files added to ipfs node?



Depending on how you add files or what you call files, you may be looking for files/ls, pin/ls?type=recursive or refs/local.

Thanks for your sharing. i’m using go-ipfs-api do add the file refer to attach, do u know the similar way using go-ipfs-api ? is there any sample documentation, sample code snip? i didn’t find any similar methods


Since you are pinning, you can use to list the things, except look at the implementation and manually pass ?type=recursive in the url.

You can also use and if you want to have file names.

Thanks for the quick reply. I would like to achieve a full list of files (go-ipgs-api) which have been added to ipfs nodes. similar to how webui did.


refer to these it will return a list of hash with type indirect, direct, recursive. i just filter by recursive type. these will be there correct list? then i can use to retrieve the file information… is that correct?

func (s *Shell) ObjectStat(key string) (*ObjectStats, error) {

var stat ObjectStats

err := s.Request("object/stat", key).Exec(context.Background(), &stat)

if err != nil {

    return nil, err


return &stat, nil


Nop, if you want what WebUI does, you need to use MFS (/files/* things). Use /files/write and files/ls and you will have your list.

i executed ipfs files ls but its show empty in fact i have added some files using ipfs add and ipfs cluster to pinned the file. any reason “ipfs files ls” return empty?

For files to show in Files.Ls you need to add them with Files.Write or, after adding them with /add, move them into MFS with Files.Mv. See ipfs files --help for info on how MFS interacts with the Pinset (it doesn’t).

Is it using ipfs files a common practice to keep track all files added to ipfs node?

If you need names or directory layout, yes.

i would like to have similar feature as below. mean i have to use the ipfs files functions? will it have any performance issue if i add file to ipfs node frequently?

Another question will be, i have a go-ipfs installed in my machine, but when i access 5001/webui it not able to show the webui. anything i missed out?

Yes, for that you must use the files functions. No big performance issue I can think of in comparison to not using them.

I am not sure, check your browser’s console, maybe there’s an useful error message there.

will “ipfs files” have issue if i would like to Containerization for ipfs node/cluster and usages persistent volume?


But IPFS Cluster does not use the “ipfs files” interface, it uses the pin/add interface. IPFS cluster carries information about file names differently (as part of the cluster data).

if i have ipfs node + ipfs cluster Containerization setup. what are the correct api i shall use there following?

  1. add
  2. pin file with expiry
  3. download file
  4. list all file which have added include it file name+ size + block

i’m currently uses the below api, please correct me if this is wrong.

  1. add ->go_ipfs_api (s *Shell) Add(r io.Reader, options …AddOpts)
    pin -> ipfs cluster Pin(ctx context.Context, ci cid.Cid, opts api.PinOptions)
  2. download file -> go_ipfs_api (s *Shell) Cat(path string) (io.ReadCloser, error) {

@hector may i know how to use ipfs-cluster/api/rest/client to add a file in go project?

See for example.

@hector Thanks… what if the file is a multipart from a web page?

You can post multipart directly to the /add endpoint. Works in the same way as the ipfs’s /add endpoint.