/** * 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; }