Skip to content

Commit

Permalink
fix: correctly upload asset if file is Buffer/ArrayBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Jan 27, 2018
1 parent e16817d commit d191dfc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/request/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const https = require('https')

const _ = require('lodash')
const debug = require('debug')('octokit:rest')
const isArrayBuffer = require('is-array-buffer')
const isStream = require('is-stream')

const errors = require('./errors')
Expand All @@ -22,7 +23,8 @@ function httpRequest (requestOptions) {
// calculate content length unless body is a stream, in which case the
// content length is already set per option
if (requestOptions.body && !isStream(requestOptions.body)) {
if (typeof requestOptions.body !== 'string') {
// stringify body unless it’s an ArrayBuffer
if (!isArrayBuffer(requestOptions.body) && !Buffer.isBuffer(requestOptions.body) && typeof requestOptions.body !== 'string') {
requestOptions.body = JSON.stringify(requestOptions.body)
}

Expand Down

0 comments on commit d191dfc

Please sign in to comment.