How can i read a file using the ipfs.files.read(CID)

library is ipfs-http-client

I’m trying to read a file’s CID like this ipfs.files.read('bafy...') as per documentation here js-ipfs/FILES.md at master · ipfs/js-ipfs · GitHub but it keeps saying error: HTTPError: paths must start with a leading slash although i should be able to read the file based on the CID

File exists on the MFS

Thank you

MFS paths are not the same as CIDs. An MFS path is more like an actual file-system path with slashes and file names, etc. If you just want to read something by a CID you can use ‘cat’ right?

why then the docs says it is possible? then the docs is wrong, right?

Oh, that must be my mistake then. My apologies. I have read some MFS docs, and used it for some testing, but not an expert, so if you’re right, then I stand corrected. :slight_smile:

please check it here and see is it a bug, I think it is js-ipfs/FILES.md at master · ipfs/js-ipfs · GitHub
:slight_smile:

1 Like