I have been playing around with IPFS a lot recently, and have been wondering how to make a download link for files that gives them a custom name. The standard <a>
tag download attribute doesn't work:
<a href="http://ipfs.io/ipfs/QmV9tSDx9UiPeWExXEeH6aoDvmihvx6jD5eLb4jbTaKGps" download="ipfs-p2p-file-system.pdf">foo</a>
Is there a way I can work around this by using JavaScript or Jquery? At a last resort I could route the files through the server, but I would prefer not to.
You can add your file by wrapping it inside a folder and therefore preserving the name of the original file. Try:
$ ipfs add -w example.txt
added QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH example.txt
added QmVFDXxAEC5iQ9ptb36dxzpNsQjVatvxhG44wK7PpRzsDE
This way, you can point to the last hash, which is a MerkleDAG Node that points to your file, preserving the name of it. Let me know if this solution works for you :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With