diff --git a/src/telegram.js b/src/telegram.js index b9247d8..e2c28bf 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -239,6 +239,9 @@ TelegramBot.prototype._formatSendData = function (type, data) { }; } else if (Buffer.isBuffer(data)) { var filetype = fileType(data); + if (!filetype) { + throw new Error('Unsupported Buffer file type'); + } formData = {}; formData[type] = { value: data, diff --git a/test/index.js b/test/index.js index c18dc3e..5b8a1fa 100644 --- a/test/index.js +++ b/test/index.js @@ -367,6 +367,17 @@ describe('Telegram', function () { done(); }); }); + + /* Currently unsupported (https://github.com/sindresorhus/file-type/pull/44) + it('should send a video from a Buffer', function (done) { + var bot = new Telegram(TOKEN); + var video = fs.readFileSync(__dirname+'/video.mp4'); + bot.sendVideo(USERID, video).then(function (resp) { + resp.should.be.an.instanceOf(Object); + done(); + }); + }); + */ }); describe('#sendVoice', function () {