How to use multiaddr-to-uri - 3 common examples

To help you get started, we’ve selected a few multiaddr-to-uri examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ipfs-shipyard / ipfs-share-files / src / bundles / files.js View on Github external
doGetArchiveURL: (hash) => async ({ dispatch, store, getIpfs }) => {
    const ipfs = getIpfs()
    const apiAddress = store.selectIpfsApiAddress()
    dispatch({ type: 'FILES_ARCHIVE_FILES' })

    // Try to use the HTTP API of the local daemon
    const url = apiAddress !== null
      ? toUri(apiAddress).replace('tcp://', 'http://').concat('/api')
      : ENDPOINTS.api

    // If no hash was passed it is to download everything
    if (!hash) {
      const files = Object.values(store.selectFiles())
      hash = await makeHashFromFiles(files, ipfs)
    }

    return {
      url: `${url}/v0/get?arg=${hash}&archive=true&compress=true`,
      filename: `shared-via-ipfs_${hash.slice(-7)}.tar.gz`
    }
  },
github ipfs-shipyard / ipfs-webui / src / bundles / config.js View on Github external
function getURLFromAddress (name, config) {
  if (!config) return null

  try {
    const address = Array.isArray(config.Addresses[name])
      ? config.Addresses[name][0]
      : config.Addresses[name]
    return toUri(address).replace('tcp://', 'http://')
  } catch (error) {
    console.log(`Failed to get url from Addresses.${name}`, error)
    return null
  }
}
github ipfs-shipyard / ipfs-desktop / src / protocol-handlers.js View on Github external
function parseAddr (addr) {
  return toUri(addr.toString().includes('/http') ? addr : addr.encapsulate('/http'))
}

multiaddr-to-uri

Convert a Multiaddr to a URI /dnsaddr/ipfs.io/http -> http://ipfs.io

MIT
Latest version published 3 years ago

Package Health Score

50 / 100
Full package analysis

Popular multiaddr-to-uri functions