ipfs / ipfs/kubo

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

Open
#3,430 4 comments 1 reaction 0 assignees View on GitHub
help wanted kind/enhancement need/analysis topic/commands
Dominant language
Go
Stars
17.1k
Forks
3.2k
Avg merge
3d 18h
Merged PRs (30d)
11

Description

#### Type: Feature

#### Priority: Impacts Developer Experience

#### Description:

It would be very useful to have a general `ipfs stat ` command or maybe `ipfs info ` or `ipfs object type ` 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:
```bash
$ ipfs add -w afile.txt
added afile.txt
added
```

I'd like to be able to do something like this:
```bash
$ ipfs object type
blob
$ ipfs object type
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
```bash
$ ipfs cat
```
and I can run
```bash
ipfs ls
```
but not the other way around — I can't `cat` a directory object nor can I meaningfully `ls` a blob object.

```bash
$ ipfs cat
Error: this dag node is a directory
```
and `ipfs ls ` doesn’t return anything at all.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.