diff --git a/src/backends/github/API.js b/src/backends/github/API.js index 407d8133f4fb..459524ddbb49 100644 --- a/src/backends/github/API.js +++ b/src/backends/github/API.js @@ -30,11 +30,6 @@ export default class API { }); } - isPrivateRepo() { - return this.request(this.repoURL) - .then(repo => repo.private); - } - requestHeaders(headers = {}) { const baseHeader = { "Content-Type": "application/json", diff --git a/src/backends/github/implementation.js b/src/backends/github/implementation.js index 92a5af598d47..2663e15dd6f4 100644 --- a/src/backends/github/implementation.js +++ b/src/backends/github/implementation.js @@ -106,49 +106,13 @@ export default class GitHub { return this.api.persistFiles(entry, mediaFiles, options); } - /** - * Pulls repo info from a `repos` response url property. - * - * Turns this: - * '/repo///...' - * - * Into this: - * '/' - */ - getRepoFromResponseUrl(url) { - return url - - // -> '/repo///...' - .slice(this.api_root.length) - - // -> [ '', 'repo', '', '', ... ] - .split('/') - - // -> [ '', '' ] - .slice(2, 4) - - // -> '/' - .join('/'); - } - async persistMedia(mediaFile, options = {}) { try { const response = await this.api.persistFiles(null, [mediaFile], options); - const repo = this.repo || this.getRepoFromResponseUrl(response.url); - const { value, size, path, fileObj } = mediaFile; - let url = `https://raw.githubusercontent.com/${repo}/${this.branch}${path}`; - - // Assets uploaded to private repos will need valid access tokens. - const isPrivateRepo = await this.api.isPrivateRepo(); - if (isPrivateRepo) { - const files = await this.api.listFiles(this.config.get('media_folder')); - const file = files.find(f => (f.sha === mediaFile.sha)); - if (file) { - url = file.download_url; - } - } - - return { id: mediaFile.sha, name: value, size: fileObj.size, url, path: trimStart(path, '/') }; + + const { sha, value, size, path, fileObj } = mediaFile; + const url = URL.createObjectURL(fileObj); + return { id: sha, name: value, size: fileObj.size, url, path: trimStart(path, '/') }; } catch(error) { console.error(error);