How to use streamifier - 10 common examples

To help you get started, we’ve selected a few streamifier 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 / js-ipfs-http-client / test / api / cat.spec.js View on Github external
apiClients.a.cat('Qme79tX2bViL26vNjPsF3DP1R9rMKMvnPYJiKTTKPrXJjq', (err, res) => {
      expect(err).to.not.exist

      // Do not blow out the memory of nodejs :)
      const bigStream = streamifier.createReadStream(testfileBig)
      streamEqual(res, bigStream, (err, equal) => {
        expect(err).to.not.exist
        expect(equal).to.be.true
        done()
      })
    })
  })
github gladchinda / advanced-multer-node-sourcecode / helpers / AvatarStorage.js View on Github external
current.image.getBuffer(mime, function(err, buffer) {
                if (that.options.storage == 'local') {
                    // create a read stream from the buffer and pipe it to the output stream
                    streamifier.createReadStream(buffer).pipe(current.stream);
                }
            });
        });
github okta / okta-sdk-java / tools / mock-okta / util.js View on Github external
let jsonBuffer;
    // If a body exists
    if (body.length) {
      const stableJsonStr = util.normalizeJsonStr(body.toString());
      jsonBuffer = new Buffer(stableJsonStr);
      req.headers['content-length'] = jsonBuffer.length.toString();
    } else {
      jsonBuffer = new Buffer(0);
      if (req.method !== 'GET') {
        req.headers['content-length'] = '0';
      }
    }

    // Stuff the buffer back into the request
    // so yakbak can still read the buffer
    const readableStream = streamifier.createReadStream(jsonBuffer);
    req.on = readableStream.on.bind(readableStream);

    return req;
  });
};
github docusign / docusign-node-client / components / envelopes.js View on Github external
name: 'SampleDocument.pdf',
        ext: 'pdf',
        source: {
          type: 'path|base64|url',
          content: 'string|buffer'
        }
      }));
    }
    switch (fileSource.type.toLowerCase()) {
      case 'path':
        download = fs.createReadStream(fileSource.content);
        break;

      /* istanbul ignore next */
      case 'base64':
        download = streamifier.createReadStream(new Buffer(fileSource.content, 'base64'));
        break;

      /* istanbul ignore next */
      case 'url':
        download = request({
          method: 'GET',
          url: fileSource.content,
          encoding: null
        });
        break;
    }
    download.pause();

    parts.push({
      headers: {
        'Content-Disposition': 'documentId=' + documentId
github smooch / smooch-core-js / test / specs / api / conversations.spec.js View on Github external
it('should throw an error', () => {
            const source = createReadStream('some source object');
            const message = {
                text: 'this is a message'
            };

            return api.uploadImage(userId, source, message).catch(() => {
                httpSpy.should.not.have.been.called;
            });
        });
    });
github smooch / smooch-core-js / test / specs / api / appUsers.spec.js View on Github external
it('should call http', () => {
            const fullUrl = `${serviceUrl}/v1/appusers/${userId}/images`;
            const source = createReadStream('some source object');
            const message = {
                text: 'this is a message'
            };

            return api.uploadImage(userId, source, message).then(() => {
                httpSpy.args[0][0].should.eq('POST');
                httpSpy.args[0][1].should.eq(fullUrl);
                httpSpy.args[0][2].should.be.instanceof(FormData);
                httpSpy.args[0][3].should.eql(authHeaders);
            });
        });
    });
github smooch / smooch-core-js / test / specs / api / attachments.spec.js View on Github external
it('should call http given access as arg', () => {
            const fullUrl = `${serviceUrl}/v1/attachments?access=public`;
            const source = createReadStream('some source object');

            return api.create('public', source).then(() => {
                httpSpy.args[0][0].should.eq('POST');
                httpSpy.args[0][1].should.eq(fullUrl);
                httpSpy.args[0][2].should.be.instanceof(FormData);
                httpSpy.args[0][3].should.eql(authHeaders);
            });
        });
github smooch / smooch-core-js / test / specs / api / attachments.spec.js View on Github external
it('should call http in object mode', () => {
            const fullUrl = `${serviceUrl}/v1/attachments?access=public&for=message&userId=userId&appUserId=appUserId`;
            const source = createReadStream('some source object');

            const params = {
                props: {
                    access: 'public',
                    for: 'message',
                    userId: 'userId',
                    appUserId: 'appUserId'
                },
                source
            };

            return api.create(params).then(() => {
                httpSpy.args[0][0].should.eq('POST');
                httpSpy.args[0][1].should.eq(fullUrl);
                httpSpy.args[0][2].should.be.instanceof(FormData);
                httpSpy.args[0][3].should.eql(authHeaders);
github openkfw / TruBudget / blockchain / src / index.js View on Github external
app.post("/chain", async (req, res) => {
  const extractPath = `/tmp/backup${Date.now()}`;
  const metadataPath = `${extractPath}/metadata.yml`;
  try {
    const unTARer = rawTar.extract();
    unTARer.on("error", err => {
      console.log(err.message);
      unTARer.destroy();
      res.status(400).send(err.message);
    });
    const extract = tar.extract(extractPath, { extract: unTARer });
    const file = streamifier.createReadStream(req.body);
    const stream = file.pipe(extract);
    stream.on("finish", async () => {
      if (fs.existsSync(metadataPath)) {
        const config = loadConfig(metadataPath);
        const valid = await verifyHash(config.DirectoryHash, extractPath);
        if (valid) {
          autostart = false;
          await stopMultichain(mcproc);
          await moveBackup(multichainDir, extractPath, CHAINNAME);
          spawnProcess(() =>
            startMultichainDaemon(
              CHAINNAME,
              externalIpArg,
              blockNotifyArg,
              P2P_PORT,
              multichainDir,
github Daniel-Hwang / web-tunnel / nodejs-websocket-server / server.js View on Github external
app.get("/__teststream", function(req, res) {
    var buf = new Buffer("ahahahaha");
    var readStream = Streamifier.createReadStream(buf);
    readStream.pipe(res);
});

streamifier

Converts a Buffer/String into a readable stream

MIT
Latest version published 10 years ago

Package Health Score

53 / 100
Full package analysis

Popular streamifier functions