How to retrieve the CID of a block file


I have a file in the blocks folder named 5W/CIQIHL6MEMRGC…

How can I retrieve its corresponding CID ?

To be clear I’d like the command ipfs ls CID to return the content of the file.

Have a good day,


You should be able to use these functions: (it needs to be on this version of the library, not latest)

where your datastore key is datastore.NewKey("/CIQYOURFILENAME").

Let me know if that works.

Perfect! Thank you Hector!

I made a small repo for that in case someone else is interested :

(sorry if the style is bad, this is my very first code in go)

1 Like