How to use the ipfs-http-client.Buffer.from 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 AudiusProject / audius-protocol / creator-node / src / routes / tracks.js View on Github external
}

    // Ensure each segment multihash in metadata obj has an associated file, else error.
    await Promise.all(metadataJSON.track_segments.map(async segment => {
      const file = await models.File.findOne({ where: {
        multihash: segment.multihash,
        cnodeUserUUID: req.session.cnodeUserUUID,
        trackUUID: null
      } })
      if (!file) {
        return errorResponseBadRequest(`No file found for provided segment multihash: ${segment.multihash}`)
      }
    }))

    // Store + pin metadata multihash to disk + IPFS.
    const metadataBuffer = Buffer.from(JSON.stringify(metadataJSON))
    const { multihash, fileUUID } = await saveFileFromBuffer(req, metadataBuffer, 'metadata')

    return successResponse({ 'metadataMultihash': multihash, 'metadataFileUUID': fileUUID })
  }))
github AudiusProject / audius-protocol / creator-node / src / routes / audiusUsers.js View on Github external
app.post('/audius_users/metadata', authMiddleware, syncLockMiddleware, handleResponse(async (req, res) => {
    // TODO - input validation
    const metadataJSON = req.body.metadata

    const metadataBuffer = Buffer.from(JSON.stringify(metadataJSON))
    const { multihash, fileUUID } = await saveFileFromBuffer(req, metadataBuffer, 'metadata')

    return successResponse({ 'metadataMultihash': multihash, 'metadataFileUUID': fileUUID })
  }))
github uprtcl / js-uprtcl / packages / connections / src / services / ipfs / ipfs.source.ts View on Github external
.then(raw => {
        let object = JSON.parse(Buffer.from(raw.value).toString());
        this.logger.log(`Object retrieved ${hash}`, object);
        return { id: hash, object: object };
      })
      .catch(e => {
github uprtcl / js-uprtcl / packages / connections / src / services / ipfs / ipfs.source.ts View on Github external
private getObjectBuffer(object: object): Buffer {
    return Buffer.from(JSON.stringify(object));
  }

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