Member data of root node

Hi,

I have a doubt on why the member data of a root node is not empty.

I uploaded a file using this command :

echo "Hello World" | ipfs add --cid-version 1 --chunker=size-4

I obtain the following CID :

bafybeiag43jli67lcov4ytqhpfxbodmhp6hjvjh73jrjid7zf73p7a6nqa

However when I use this command

ipfs dag get bafybeiag43jli67lcov4ytqhpfxbodmhp6hjvjh73jrjid7zf73p7a6nqa | jq

The member data is supposed to be empty because this root node is supposed to only store the links to the children node who stores the raw bytes of my file.

"Data": {
    "/": {
      "bytes": "CAIYDCAEIAQgBA"
    }

My question is to what corresponds “CAIYDCAEIAQgBA”. Is it the Unixfs Wrapper ? Is it something else ? How to decode it ?

thanks

It is a base64 encoded unixfs protobuf, without the = padding characters
used in standard base64. Since it is 14 bytes long and base64 should
always be padded to a four-byte boundary, we know we need two padding
characters. On Linux with the base64 and protoc tools, we can decode it
with definitions from github.com/go-unixfs/pb/unixfs.proto like so:

echo 'CAIYDCAEIAQgBA==' |base64 -d \
  |protoc --decode=unixfs.pb.Data unixfs.proto

And here’s the human-readable description that protoc --decode gives:

Type: File
filesize: 12
blocksizes: 4
blocksizes: 4
blocksizes: 4

Hope this helps.

1 Like

Thanks a lot. :slight_smile:

I just changed a little bit your command to this

echo "CAIYDCAEIAQgBA==" | base64 -d | protoc --decode=unixfs.pb.Data unixfs.proto

Because in my shell I had an error when running yours.

Have a great day

Apologies; that was a typo, and I edited my earlier post to fix the
command.