diff --git a/octokit.coffee b/octokit.coffee index 972615a6..dc6d82fb 100644 --- a/octokit.coffee +++ b/octokit.coffee @@ -791,15 +791,17 @@ makeOctokit = (newPromise, allPromises, XMLHttpRequest, base64encode, userAgent) # Post a new blob object, getting a blob SHA back # ------- @postBlob = (content, isBase64) -> - if typeof (content) is 'string' - # Base64 encode the content if it is binary (isBase64) - content = base64encode(content) if isBase64 - + if isBase64 content = - content: content - encoding: 'utf-8' - - content.encoding = 'base64' if isBase64 + content: content, + encoding: 'base64' + else + if typeof (content) is 'string' + # Base64 encode the content if it is binary (isBase64) + content = base64encode(content) if isBase64 + content = + content: content + encoding: 'utf-8' _request('POST', "#{_repoPath}/git/blobs", content) .then (res) => diff --git a/octokit.js b/octokit.js index 3d033435..ed09ce42 100644 --- a/octokit.js +++ b/octokit.js @@ -776,17 +776,21 @@ }; this.postBlob = function(content, isBase64) { var _this = this; - if (typeof content === 'string') { - if (isBase64) { - content = base64encode(content); - } + if (isBase64) { content = { content: content, - encoding: 'utf-8' + encoding: 'base64' }; - } - if (isBase64) { - content.encoding = 'base64'; + } else { + if (typeof content === 'string') { + if (isBase64) { + content = base64encode(content); + } + content = { + content: content, + encoding: 'utf-8' + }; + } } return _request('POST', "" + _repoPath + "/git/blobs", content).then(function(res) { return res.sha;