From ba8604b9544ae12dd55f4046186df889b487e546 Mon Sep 17 00:00:00 2001 From: Jose Wdison de Souza Date: Mon, 12 Apr 2021 15:13:06 -0300 Subject: [PATCH] Update Repository.js to works if png Using the raw parameter within the options of the writeFile method, this tool works with the sending of png images, it has not been tested with other files, but I think this solution will work for others as well. ``` writePng(fileNamePng:string,base64Png:any,commitMsg:string=''){ let initialMessage=commitMsg||'Commit de '+base64Png; let option = {encode:false,raw:true} const promise = this.bagRepo.writeFile('master', base64Png, base64Png, initialMessage, option); promise.then((valor:any) => { // console.log(valor); },this.initRepo); return promise; } ``` --- lib/Repository.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Repository.js b/lib/Repository.js index 74452dde..931a16e8 100644 --- a/lib/Repository.js +++ b/lib/Repository.js @@ -784,9 +784,9 @@ class Repository extends Requestable { return this.getSha(branch, filePath) .then((response) => { commit.sha = response.data.sha; - return this._request('PUT', `/repos/${this.__fullname}/contents/${filePath}`, commit, cb); + return this._request('PUT', `/repos/${this.__fullname}/contents/${filePath}`, commit, cb, options.raw); }, () => { - return this._request('PUT', `/repos/${this.__fullname}/contents/${filePath}`, commit, cb); + return this._request('PUT', `/repos/${this.__fullname}/contents/${filePath}`, commit, cb, options.raw); }); }