How does ipfs find the names of files?

From @kevinsimper on Thu Aug 18 2016 11:25:25 GMT+0000 (UTC)

If you hash a directory, then the files inside that hash can be pointed at with their original name? How is that possible, because each file can still be addressed individually by their hash.


Copied from original issue: https://github.com/ipfs/faq/issues/163

From @Ghoughpteighbteau on Thu Aug 18 2016 16:38:17 GMT+0000 (UTC)

The base component of everything in IPFS is the “Block”. and the block basically can be a list of names to hashes, or a list sub blocks and a blob.

~ $ ipfs object get QmSszskauNW84RVSjuKwKhi1uv8xkgDG2dUiaWEZaMM21S | jq
{
  "Links": [
    {
      "Name": "README.md",
      "Hash": "Qmbs8nJ2pDFUXbrxKgQdok5F3j46CeQ6H3SKiSqShzhtkE",
      "Size": 167
    },
    {
      "Name": "assets",
      "Hash": "QmY9hi4p7hhZWQ1KmkcUdurXTuZewRxs7SPZfEuAm92nfg",
      "Size": 2085821
    },
    {
      "Name": "index.html",
      "Hash": "QmZV31M1TXgVZYEGEYotbU24BnEm4QL627cGpMcUGGFPCH",
      "Size": 95193
    },
    {
      "Name": "mapbox-gl.css",
      "Hash": "QmXYv8fM2khaFR7HRAaipPQgvHpJQJ6xqRrLEeMnRQdQn6",
      "Size": 6404
    },
    {
      "Name": "mapbox-gl.js",
      "Hash": "QmeWwLgpujVtj6wpwKcfQZuq5gUdWwnFTc4NPkeyVi9Vo9",
      "Size": 322137
    },
    {
      "Name": "mapbox-gl.js.map",
      "Hash": "QmTvQQjBd3HUi65hyFdeejCLvEMD5TZsUSsEk3ZchdaRHn",
      "Size": 1139693
    }
  ],
  "Data": "\b\u0001"
}
~ $ ipfs object get QmTAJnMHpMLL8GF3WZjEAoMWo2eLDscBxBvCuLU3zCCZhp | jq
{
  "Links": [
    {
      "Name": "",
      "Hash": "QmPEEQPsErRnPhXr4Zst5P2Zfmstcxxm59iNjDzz2dhYqy",
      "Size": 45623854
    },
    {
      "Name": "",
      "Hash": "QmWAoGsvLQTPH54uqx3H3kGFHJ99GdztygNLKiCKsZ5T6U",
      "Size": 6796349
    }
  ],
  "Data": "\b\u0002\u0018���\u0018 ���\u0015 �۞\u0003"
}

so Readme.md is addressed in two ways in IPFS. Indirectly through this directory Block.

~ $ ipfs cat QmSszskauNW84RVSjuKwKhi1uv8xkgDG2dUiaWEZaMM21S/README.md
# OSM vector tiles on IPFS

...

or directly through its hash.

~ $ ipfs cat Qmbs8nJ2pDFUXbrxKgQdok5F3j46CeQ6H3SKiSqShzhtkE
# OSM vector tiles on IPFS
...

From @kevinsimper on Thu Aug 18 2016 16:47:18 GMT+0000 (UTC)

Okay, really good answer :+1: I have not used object yet!

From @Kubuxu on Thu Aug 18 2016 17:01:17 GMT+0000 (UTC)

Only note: there is difference between objects and blocks, blocks are uninterpreted blobs (ipfs block) and objects are blocks in unifs format.