diff --git a/.all-contributorsrc b/.all-contributorsrc index 65d3b53fe6e4..ebb3b65edfbe 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -457,6 +457,16 @@ "contributions": [ "doc" ] + }, + { + "login": "Quicksaver", + "name": "LuΓ­s Miguel", + "avatar_url": "https://avatars3.githubusercontent.com/u/802086?v=4", + "profile": "https://github.com/Quicksaver", + "contributions": [ + "bug", + "code" + ] } ] } diff --git a/README.md b/README.md index 4d91d2188ce3..e11c71ddab53 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Netlify CMS -[![All Contributors](https://img.shields.io/badge/all_contributors-56-orange.svg)](#contributors) +[![All Contributors](https://img.shields.io/badge/all_contributors-57-orange.svg)](#contributors) [![](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/netlify/netlifycms) A CMS for static site generators. Give non-technical users a simple way to edit @@ -57,6 +57,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds | [
Artem Govorov](http://dm.gl)
| [
CΓ©dric Delpoux](http://xuopled.netlify.com/)
| [
imorente](https://github.com/imorente)
| [
David Francoeur](http://davidfrancoeur.com)
| [
Rusta](https://github.com/Rusta)
| [
Henrik Lau Eriksson](http://henrik.laueriksson.com)
| [
Kraig Walker](https://www.kraigwalker.com)
| | [
Rich Cook](http://www.TalesofMurder.com)
| [
Damien Van Der Windt](https://github.com/damienvdw)
| [
Matt Jared](http://mattjared.github.io/)
| [
bruce-one](https://github.com/bruce-one)
| [
Frank Taillandier](https://frank.taillandier.me)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=DirtyF "Documentation") | [
Aquib Master](http://aquibm.com/)
[πŸ’»](https://github.com/netlify/netlify-cms/commits?author=aquibm "Code") | [
Eric Jinks](http://ericjinks.com)
[πŸ’»](https://github.com/netlify/netlify-cms/commits?author=Jinksi "Code") | | [
Tony Alves](https://github.com/talves)
[πŸ’»](https://github.com/netlify/netlify-cms/commits?author=talves "Code") | [
Ernie Bello](http://ern.me)
[πŸ›](https://github.com/netlify/netlify-cms/issues?q=author%3Aebello "Bug reports") | [
Alexander Kushi-Willis](https://ackushiw.com)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=ackushiw "Documentation") | [
Igor Kuznetsov](http://www.igk.ru)
[πŸ›](https://github.com/netlify/netlify-cms/issues?q=author%3Aigk1972 "Bug reports") [πŸ’»](https://github.com/netlify/netlify-cms/commits?author=igk1972 "Code") [πŸ”Œ](#plugin-igk1972 "Plugin/utility libraries") | [
Tim Erickson](http://neutyp.com)
[🎨](#design-neutyp "Design") | [
David Jones](http://davidejones.com)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=davidejones "Documentation") | [
Henrique Cavalieri](https://kaordica.com.br)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=hcavalieri "Documentation") | +| [
LuΓ­s Miguel](https://github.com/Quicksaver)
[πŸ›](https://github.com/netlify/netlify-cms/issues?q=author%3AQuicksaver "Bug reports") [πŸ’»](https://github.com/netlify/netlify-cms/commits?author=Quicksaver "Code") | This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome! \ No newline at end of file diff --git a/src/backends/github/implementation.js b/src/backends/github/implementation.js index f357b6c82ff9..cd2bd4657e30 100644 --- a/src/backends/github/implementation.js +++ b/src/backends/github/implementation.js @@ -136,8 +136,18 @@ export default class GitHub { const response = await this.api.persistFiles(null, [mediaFile], options); const repo = this.repo || this.getRepoFromResponseUrl(response.url); const { value, size, path, fileObj } = mediaFile; - const url = `https://raw.githubusercontent.com/${repo}/${this.branch}${path}`; - return { id: response.sha, name: value, size: fileObj.size, url, path: trimStart(path, '/') }; + let url = `https://raw.githubusercontent.com/${repo}/${this.branch}${path}`; + + // Assets uploaded to private repos will need valid access tokens. + const files = await this.api.listFiles(this.config.get('media_folder')); + for (let file of files) { + if (file.sha === mediaFile.sha) { + url = file.download_url; + break; + } + } + + return { id: mediaFile.sha, name: value, size: fileObj.size, url, path: trimStart(path, '/') }; } catch(error) { console.error(error);