How to use the ipfs-http-client 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 status-im / liquid-funding / src / utils / ipfs.js View on Github external
import IPFS from 'ipfs'
import ipfsClient from 'ipfs-http-client'
import { Buffer } from 'buffer'
import { Matcher } from '@areknawo/rex'
import { getImageType } from './images'

const ipfsMatcher = new Matcher().begin().find('ipfs/')
export const ipfs = new IPFS()
const ipfsHttp = ipfsClient({ host: 'test-ipfs.status.im', port: '2053', protocol: 'https' })
const ipfsHttpTheGraph = ipfsClient({ host: 'api.thegraph.com', 'api-path': '/ipfs/api/v0/', protocol: 'https', port: '443' })

window.ipfsHttp = ipfsHttp
window.ipfsHttpTheGraph = ipfsHttpTheGraph
window.jsIPFS = ipfs

ipfs.on('ready', () => {
  console.log('Node is ready to use!')
  // Add status ipfs node as peer
  ipfs.bootstrap.add('/ip4/35.188.209.83/tcp/4001/ipfs/QmZqW6QHdDVyHMvYktpA1PAuKgvqhwumbuFqFB5URedSbA')
})


export const isIpfs = str => ipfsMatcher.test(str)
export const captureFile = (event, cb, imgCb) => {
  event.stopPropagation()
github pandonetwork / pando / packages / pando.js / src / plant / index.ts View on Github external
public async extract(_organization: string, _organism: string): Promise<void> {
    const ipfs = new IPFSClient({ host: 'localhost', port: '5001', protocol: 'http' })
    const organization = await this.organizations.load({ name: _organization })
    const organism = await organization.organisms.load({ name: _organism })

    const head = await organism.head()

    if (head.blockstamp !== 0) {
      const fiber = (await this.fibers.current()) as Fiber
      await fiber.snapshot(`Automatic snapshot before extraction of ${_organization}:${_organism}`)
      await this._clear()

      const metadata = await ipfs.dag.get(head.metadata)
      await this._download(metadata.value.tree)
    }
  }
github aragon / aragon-cli / packages / toolkit / src / ipfs / misc.js View on Github external
export function connectThroughHTTP(address) {
  if (typeof address === 'string') {
    return ipfsHttpClient(parseAddressAsURL(address))
  }

  return ipfsHttpClient(address)
}
github pandonetwork / pando / packages / pando-repository / app / src / components / PushRequest.js View on Github external
constructor(props) {
    super(props)

    this.ipfs = IPFS({ host: 'ipfs.infura.io', port: '5001', protocol: 'https' })
    this.ipld = new IPLD({
      blockService: this.ipfs.block,
      formats: [IPLDGit],
    })

    this.state = {
      diffViewState: 'split',
      diffs: [],
      highlightLine: [],
    }
  }
github pandonetwork / pando / packages / git-remote-pando / src / lib / ipld.ts View on Github external
constructor(helper: Helper) {
    const url = new URL(helper.config.ipfs.gateway)
    this.helper = helper
    this._ipfs = IPFS({ host: url.hostname, port: url.port, protocol: url.protocol.slice(0, url.protocol.length - 1) })
    this._ipld = new IPLD({
      blockService: this._ipfs.block,
      formats: [IPLDGit],
    })
  }
github AutarkLabs / open-enterprise / apps / discussions / app / ipfs / index.js View on Github external
import ipfsClient from 'ipfs-http-client'

export const ipfs = ipfsClient({
  host: 'localhost',
  port: '5001',
  protocol: 'http',
})
github pandonetwork / pando / packages / pando.js / src / plant / index.ts View on Github external
private async _download(cid: string, relativePath = ''): Promise<void> {
    const ipfs = new IPFSClient({ host: 'localhost', port: '5001', protocol: 'http' })
    const entries = await ipfs.ls(cid)

    for (const entry of entries) {
      if (entry.type === 'dir') {
        await this._download(entry.hash, npath.join(relativePath, entry.name))
        await fs.ensureDir(npath.join(this.paths.root, this.paths.root, relativePath, entry.name))
      } else {
        const buffer = await ipfs.cat(entry.hash)
        await fs.ensureFile(npath.join(this.paths.root, relativePath, entry.name))
        await fs.writeFile(npath.join(this.paths.root, relativePath, entry.name), buffer)
      }
    }
  }
github pandonetwork / pando / packages / scheme-democracy / app / components / Browser.js View on Github external
constructor(props) {
    super(props)
    this.ipfs = IPFS({ host: 'localhost', port: '5001', protocol: 'http' })
    this.forward = this.forward.bind(this)
    this.backward = this.backward.bind(this)
    this.display = this.display.bind(this)
    this.goto = this.goto.bind(this)
  }
github uprtcl / js-uprtcl / packages / cortex / src / connections / ipfs.connection.ts View on Github external
protected async connect(): Promise<void> {
    this.client = ipfsClient(this.clientOptions);
  }

ipfs-http-client

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