From 85255a1a3b82b6569588877871925e465e09d7c9 Mon Sep 17 00:00:00 2001 From: Gregor Date: Mon, 25 Dec 2017 12:21:43 -0800 Subject: [PATCH] fix: uploadAsset with `file: fs.createReadStream()` --- lib/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/index.js b/lib/index.js index 74af1ca1c2..dfc04e669e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -2,6 +2,7 @@ var HttpsProxyAgent = require('https-proxy-agent') var getProxyForUrl = require('proxy-from-env').getProxyForUrl +var isStream = require('is-stream') var toCamelCase = require('lodash/camelCase') var urlTemplate = require('url-template') @@ -777,6 +778,10 @@ var Client = module.exports = function (config) { } if (hasFileBody) { + if (isStream(msg.file)) { + return msg.file.pipe(req) + } + req.write(Buffer.from(msg.file)) }