[Proposal] Read `.iplink` files to allows adding of arbitrary reference in `ipfs add -r`

Hi,

Currently there are mainly 2 easy way to create objects in bash (excluding mfs) :

  • ipfs add
  • ipfs object

Most of the time I use ipfs add, but I would like to also be able to create arbitrary links in my folders without using a second round of ipfs object (ipfs object get annoying very quickly if you have multiples files in multiple sub directory).

TL;DR:

What I would like to do is just write my CID to a .iplink file and when ipfs add -r add this file (and maybe the correct option is set ?) this file wouldn’t get add but replaced by a reference to the hash written in the .iplink.

The string in front of .iplink would be the name in the current folder.

Praticaly

First I would create this :

$ tree First/ && ipfs add -r First/
First/
├── a
└── b

0 directories, 2 files
added QmVvUkSZqM2EG1SK9s49uN6pizNhXVFHpuJgh53my4A4pP First/a
added QmVC2Pnz75eHUGoQp6QPt6e4dafY1g3CrkKytqymCd6Vgp First/b
added QmYyE1ZQw9W8uxSBqhesJT9xgqjzN5pW51fwGXELEHxxFe First

Then I would create my .iplink :

$ echo "QmYyE1ZQw9W8uxSBqhesJT9xgqjzN5pW51fwGXELEHxxFe" > Second/first.iplink
$ echo "QmYyE1ZQw9W8uxSBqhesJT9xgqjzN5pW51fwGXELEHxxFe" > Second/a/f.iplink
$ ipfs add -rQ Second
QmakkHgkizoGZtgKpjAQroCV7pGcSyYnbeRRgsJzLXBbTb

Since I’ve did a mess with names you can only download it using ipfs get (web gateway is broken), this is also a good thing for .iplink, names are weird with their XX<Name>.
But still the result is :

$ tree QmakkHgkizoGZtgKpjAQroCV7pGcSyYnbeRRgsJzLXBbTb/
QmakkHgkizoGZtgKpjAQroCV7pGcSyYnbeRRgsJzLXBbTb/
├── a
│   ├── f
│   │   ├── a
│   │   └── b
│   └── test
└── first
    ├── a
    └── b

Even if f and first are not the same here, they do have the same hash and benefits from a single download.

The only last thing I have to say is that manually doing this object was painfull for what this is .iplinks or something similar would be more than welcome.

1 Like