How to create a download link for files hosted in IPFS?

Recently, I often met with IPFS and wondered how to make a link to download files that give them a custom name. The standard tag upload attribute <a>does not work:

<a href="http://ipfs.io/ipfs/QmV9tSDx9UiPeWExXEeH6aoDvmihvx6jD5eLb4jbTaKGps" download="ipfs-p2p-file-system.pdf">foo</a>

Is there a way around this using JavaScript or jQuery? As a last resort I could route files through the server, but I would prefer not to do this.

+4
source share
1 answer

You can add your file by wrapping it inside a folder and, therefore, saving the name of the source file. Try:

$ ipfs add -w example.txt
added QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH example.txt
added QmVFDXxAEC5iQ9ptb36dxzpNsQjVatvxhG44wK7PpRzsDE

, MerkleDAG Node, , . , :)

+3

Source: https://habr.com/ru/post/1618549/


All Articles