Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: General cli command for getting "type" info about a hash #3430

Open
flyingzumwalt opened this issue Nov 28, 2016 · 4 comments
Open
Labels
help wanted Seeking public contribution on this issue kind/enhancement A net-new feature or improvement to an existing feature need/analysis Needs further analysis before proceeding topic/commands Topic commands

Comments

@flyingzumwalt
Copy link

Type: Feature

Priority: Impacts Developer Experience

Description:

It would be very useful to have a general ipfs stat <thing> command or maybe ipfs info <hash> or ipfs object type <hash> that would tell you, at the very least, what type of object the hash corresponds to (ie. blob, directory, etc.)

Example

If I do this:

$ ipfs add -w afile.txt
added <blob-hash> afile.txt
added <directory-hash> 

I'd like to be able to do something like this:

$ ipfs object type <blob-hash>
blob
$ ipfs object type <directory-hash>
directory

... really I'd be happy with any means of getting ipfs to tell me the object's type. Currently the only way to figure out what type of object a hash represents is to try commands with the hash and inspect the error messages for type mis-matches.

Can't You use ipfs object stat?

It seems like ipfs object stat might provide this info but it just returns info like:

NumLinks: 1
BlockSize: 66
LinksSize: 64
DataSize: 2
CumulativeSize: 123

So you could potentially add type info into the response from this command, but currently ipfs object stat isn't returning any type info.

Why do this?

I'd like to be able to know that QmQBcXur... is a blob and QmWw4vu... is a directory because different types of objects require different commands to be useful. Given a hash, I need to know its type in order to know what commands to use in order to make sense of it:

I can run

$ ipfs cat <blob-hash> 

and I can run

ipfs ls <directory-hash>

but not the other way around — I can't cat a directory object nor can I meaningfully ls a blob object.

$ ipfs cat <directory-hash>
Error: this dag node is a directory

and ipfs ls <blob-hash> doesn’t return anything at all.

@whyrusleeping whyrusleeping added topic/commands Topic commands kind/enhancement A net-new feature or improvement to an existing feature labels Nov 28, 2016
@whyrusleeping
Copy link
Member

I'm picturing an ipfs info command that does a lot of smart magic stuff to print out information on whatever you paste in. Things like being able to deal with raw data, unixfs, non-unixfs, peer IDs, paths, multiaddrs and so on

@flyingzumwalt
Copy link
Author

If that info is available in ipfs, then yeah! Bring it on.

@whyrusleeping whyrusleeping added the need/analysis Needs further analysis before proceeding label Nov 28, 2016
@whyrusleeping whyrusleeping added the help wanted Seeking public contribution on this issue label Sep 2, 2017
@dokterbob
Copy link
Contributor

As developer of ipfs-search.com I would love this feature. :)

@dokterbob
Copy link
Contributor

Specifically, as the only way to figure out the type of a hash currently is file/ls (over the JSON API), which fails for non-protobuf nodes.

Ref: ipfs-search/ipfs-search#51

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Seeking public contribution on this issue kind/enhancement A net-new feature or improvement to an existing feature need/analysis Needs further analysis before proceeding topic/commands Topic commands
Projects
No open projects
Development

No branches or pull requests

3 participants