Skip to content
This repository was archived by the owner on Feb 8, 2023. It is now read-only.
This repository was archived by the owner on Feb 8, 2023. It is now read-only.

ipfs-download.js - a tool to make "IPFS Download" links try their best #239

Open
@jbenet

Description

@jbenet

We've often discussed how to make it easy to download things with IPFS, particularly in the "almost all http" setting (eg a website served over http but that can serve js to a browser). Today I saw this archive: https://mcarchive.net/mods/ee which has "IPFS Download" buttons and figured that:

(1) it would be great if clicking that link would:

  • try to use a local ipfs daemon to fetch things (local to the browser or the OS)
  • fallback to try to use a js-ipfs node on the page to download p2p among the nodes on this site
  • fallback to straight http from the ipfs gateway (in js)
  • fallback to a regular https://ipfs.io/ipfs/... link in case the browser does not run js (and works with curl/wget archiving).

(2) we had a small library that did all of the above for users, so that users only had to include a js file and it would automagically try its best to download "ipfs links" with IPFS.

  • where "ipfs link" is defined as: https?://ipfs.io/ip[fn]s/ or dweb://... or ipfs://... or fs:// ... etc. (we should make a short spec for this...)
<script src="https://ipfs.io/ipfs/<hash-of-lib>/ipfs-downloader.js"></script>


<!-- the ipfs-downloader.js above will:
 - intercept clicking these links 
   - if they're ipfs links
     - will try its best to use IPFS to download them
-->
<a href="https://ipfs.io/ipfs/<hash-of-dir-1>/file1">File 1</a>
<a href="https://ipfs.io/ipfs/<hash-of-dir-1>/file2">File 2</a>
<a href="https://ipfs.io/ipfs/<hash-of-dir-2>/file3">File 3</a>
<a href="https://ipfs.io/ipfs/<hash-of-file-4>">File 4</a>
<a href="https://ipfs.io/ipfs/<hash-of-dir-3/a/b/c/file5">File 5</a>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions