Example #1
0
    listFiles(root, out, options, function (err, blacklisted) {
      if (err) return out.destroy(err)

      if (blacklisted.length > 0) {
        return out.destroy(new Error(
          blacklisted.length + ' blacklisted: \n\n' +
          blacklisted.join('\n')
        ))
      }

      out.end()
    })
Example #2
0
  return (hash, opts) => {
    opts = opts || {}

    const pt = new Stream.PassThrough()

    try {
      hash = cleanCID(hash)
    } catch (err) {
      if (!v.ipfsPath(hash)) {
        return pt.destroy(err)
      }
    }

    const query = {
      offset: opts.offset,
      length: opts.length
    }

    send({ path: 'cat', args: hash, buffer: opts.buffer, qs: query }, (err, stream) => {
      if (err) { return pt.destroy(err) }

      pump(stream, pt)
    })

    return pt
  }
Example #3
0
  return (path, opts) => {
    opts = opts || {}

    const pt = new Stream.PassThrough({ objectMode: true })

    try {
      path = cleanCID(path)
    } catch (err) {
      if (!v.ipfsPath(path)) {
        return pt.destroy(err)
      }
    }

    const request = { path: 'get', args: path, qs: opts }

    // Convert the response stream to TarStream objects
    send.andTransform(request, TarStreamToObjects, (err, stream) => {
      if (err) { return pt.destroy(err) }

      pump(stream, pt)
    })

    return pt
  }
Example #4
0
    send.andTransform(request, TarStreamToObjects, (err, stream) => {
      if (err) { return pt.destroy(err) }

      pump(stream, pt)
    })
Example #5
0
    send({ path: 'cat', args: hash, buffer: opts.buffer, qs: query }, (err, stream) => {
      if (err) { return pt.destroy(err) }

      pump(stream, pt)
    })