How can I find the directory associated with an ipfs file?

Viewed 272

If I have the link to an IPFS file, how would I go up one directory?

I am looking for the equivalent of using cd .. in Windows CLI. I've been using the IPFS Desktop program and inputting the IPFS hash in the 'Files' section. It loads files properly but doesn't allow me to go up one directory above the file. I can learn to use CLI as well but I haven't found anything on this online.

Thank you

1 Answers

IPFS CIDs work top-down. A directory will have a list of files in it, and each file is unaware of what directory it's in. If you had a file in DirA/DirB/File.txt then you had the same file in DirC/File.txt and both File.txt were identical, they'd have the same CID, with no information about what's above them.

In short: You can't, because the CID contains no information about what's above it. This property is by design, and how IPFS achieves natural de-duplication.

Related