How to use the ipfs-http-client.create function in ipfs-http-client

To help you get started, we’ve selected a few ipfs-http-client 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 ambientsprotocol / ambc / src / cli.js View on Github external
;(async (argv) => {
  let ipfs

  try {
    if (argv['ipfs-api']) {
      // --ipfs-api option
      const IPFS = require('ipfs-http-client')
      const addr = multiaddr(argv['ipfs-api'])
      const nodeAddress = addr.nodeAddress()
      ipfs = new IPFS(nodeAddress.address, nodeAddress.port)
    } else {
      const IPFS = require('ipfs')
      ipfs = await IPFS.create({ start: false })
  } catch (e) {
    throw new Error('Please use npm to install either `ipfs` or `ipfs-http-client`.')

  // Register new MIME type for .ambient files
  mime.extensions['text/ambients'] = ['ambient']
  mime.types.ambient = 'text/ambients'

  const file = fs.readFileSync(argv.input).toString().trim()

  let result
  switch (mime.lookup(argv.input)) {
    case 'application/javascript':
      result = await output(ipfs, file, argv); break


A client library for the IPFS HTTP API

Apache-2.0 OR MIT
Latest version published 22 days ago

Package Health Score

95 / 100
Full package analysis