let tarStream = new stream.PassThrough();
/** * Return a readable stream for file. * * `fileStream.path` is the specified file ID i.e. `fileId`. * `fileStream` emits event `info` passing a single argument i.e. * `info` with the interface `{ uri }` where `uri` is the URI of the * file on Telegram servers. * * This method is a sugar extension of the [getFileLink](#TelegramBot+getFileLink) method, * which returns the full URI to the file on remote server. * * @param {String} fileId File identifier to get info about * @param {Object} [options] Additional Telegram query options * @return {stream.Readable} fileStream */ getFileStream(fileId, form = {}) { const fileStream = new stream.PassThrough(); fileStream.path = fileId; this.getFileLink(fileId, form) .then((fileURI) => { fileStream.emit('info', { uri: fileURI, }); pump(streamedRequest(Object.assign({ uri: fileURI }, this.options.request)), fileStream); }) .catch((error) => { fileStream.emit('error', error); }); return fileStream; }
let tarStream = new stream.PassThrough();
transit.opts.maxChunkSize = 100; let randomData = crypto.randomBytes(256); // length > maxChunkSize => will be splitted to several chunks let stream = new Stream.PassThrough();
it("should accept Readable streams with deferred size", async function () { var input = new stream.PassThrough(); var options = { httpStack: new TestHttpStack(), endpoint: "/uploads", chunkSize: 7, uploadLengthDeferred: true }; input.end("hello WORLD"); await expectHelloWorldUpload(input, options); });
it("should reject streams without specifying the size", async function () { var input = new stream.PassThrough(); var options = { endpoint: "/uploads", chunkSize: 100, onError: waitableFunction("onError") }; var upload = new tus.Upload(input, options); upload.start(); const err = await options.onError.toBeCalled; expect(err.message).toBe("tus: cannot automatically derive upload's size from input and must be specified manually using the `uploadSize` option"); });
originController.createOrigin(`${opts.prefix || '/identicon'}/:token`, async ({ token, size, width }) => { debug('Identicon origin'); // We can use any size/width param from the recipe to make sure the size will match const reqOpts = Object.assign({}, opts); if (size) reqOpts.size = size; else if (width) reqOpts.size = width; const img = new Identicon(token, reqOpts); const bufferStream = new stream.PassThrough(); bufferStream.end(await img.render()); return bufferStream; })
var interceptorFactory = function() { var interceptor = new stream.PassThrough() interceptor.on('end', function() { intercepted = true }) return interceptor }
constructor(res) { this.filters = new Array() this.streamFactories = new Array() this.streams = new Array() this.decompressor = new stream.PassThrough() this.compressor = new stream.PassThrough() this.writeOrig = res.write this.endOrig = res.end this.writeHeadOrig = res.writeHead this.headersChecked = false }
function createReadStream(filePath, options) { const Stream = require("stream"); const PassThroughStream = Stream.PassThrough; const outStream = new PassThroughStream(); getFileStream(filePath, options) .then(stream => { stream.pipe(outStream); }) .catch(err => { outStream.emit("error", err); }); return outStream; }
beforeEach(function() { intercepted = false interceptor = new stream.PassThrough() interceptor.on('end', () => { intercepted = true }) })
const importFile = function (buffer, container, filename) { const bufferStream = new stream.PassThrough() bufferStream.end(buffer) return storage.store(container, filename, bufferStream) }
it("should reject streams without specifying the chunkSize", async function () { var input = new stream.PassThrough(); var options = { endpoint: "/uploads", onError: waitableFunction("onError") }; var upload = new tus.Upload(input, options); upload.start(); const err = await options.onError.toBeCalled; expect(err.message).toBe("cannot create source for stream without a finite value for the `chunkSize` option"); });
it("should accept Readable streams", async function () { var input = new stream.PassThrough(); var options = { httpStack: new TestHttpStack(), endpoint: "/uploads", chunkSize: 7, uploadSize: 11 }; input.end("hello WORLD"); await expectHelloWorldUpload(input, options); });
var interceptorFactory2 = function() { var interceptor = new stream.PassThrough() interceptor.on('end', function() { intercepted2 = true }) return interceptor }