Find the type of an IPFS path

Hi, I’m running Kubo v0.14.0 and would like to know what’s the correct and reliable way to learn the type of an IPFS path. That is, if it is a UnixFS object, and if it’s a directory or a file.

I know of /v0/ls but that doesn’t return the type of the path itself, only of the links. Plus I don’t know beforehand if the path is even UnixFS, the call may result in an error…

Couldn’t find any other relevant endpoint on the docs: Kubo RPC API | IPFS Docs

ipfs files stats /ipfs/CID

1 Like

It’s working, thanks a lot!

But I thought all of the /v0/files/* were only for MFS, nothing else. Looking at ipfs files --help it says “Interact with unixfs files.” but I don’t remember this… Maybe it has changed since I first started using it.

BTW what happens if the path doesn’t point to an UnixFS object? I don’t think I have any to try here…

the files namespace do is MFS.
However if you prefix paths with /ipfs/ the MFS code recognise they are normal IPFS locations.

You can do this for example ipfs files cp /ipfs/foo /bar to “copy” (it just add the link) a file to your MFS.

Yeah that makes sense. Thanks again!