github-api: Accessing/Downloading 个文件(不使用 `getArchive`)
github-api: Accessing/Downloading Files (without using `getArchive`)
```
var GitHubApi = require("github");
var github = new GitHubApi({
debug: true
});
github.authenticate({
type: "oauth",
token: <token>
});
github.repos.getContent({
user: "user-name",
repo: "repo-with-build-dir",
path: "./build",
ref: "some-ref",
}, function(err, res) {
console.log(err, res.content);
});
```
我得到的结果是这样的:
[
{ name: '.htaccess', path: 'build/.htaccess', sha: 'someSha', size: 1787,
url:'https://api.github.com/repos/sapo/fd1/contents/build/.htaccess?ref=refs/heads/development',
html_url:'https://github.com/sapo/fd1/blob/refs/heads/development/build/.htaccess',
git_url: 'https://api.github.com/repos/sapo/fd1/git/blobs/someSha',
download_url:'https://raw.githubusercontent.com/sameRepo/fd1/refs/heads/development/build/.htaccess?token=someToken',
type: 'file' }
]
Problem/Issue
每当我尝试直接在浏览器中访问任何 url - html_url
、git_url
、download_url
- 我都会收到 404 not found
错误。
我想要实现的目标:
我需要能够将 link 传递给 S3.upload 方法。所以基本上,将这些文件复制到 S3 存储桶。
问题
你能解释一下为什么我会收到 404 错误吗?另外,关于如何使用 url 下载文件内容的任何想法?感谢我能得到的任何指示。
谢谢。
Whenever I attempt to access any the urls' directly in the browser - html_url, git_url, download_url - I get a 404 not found error.
因为我无法访问 https://github.com/sapo/fd1,我想它是一个私有存储库。
见Why am I getting a 404 error on a repository that exists?
To troubleshoot, ensure you're authenticating correctly, your OAuth access token has the required scopes, and third-party application restrictions are not blocking access.
```
var GitHubApi = require("github");
var github = new GitHubApi({
debug: true
});
github.authenticate({
type: "oauth",
token: <token>
});
github.repos.getContent({
user: "user-name",
repo: "repo-with-build-dir",
path: "./build",
ref: "some-ref",
}, function(err, res) {
console.log(err, res.content);
});
```
我得到的结果是这样的:
[
{ name: '.htaccess', path: 'build/.htaccess', sha: 'someSha', size: 1787,
url:'https://api.github.com/repos/sapo/fd1/contents/build/.htaccess?ref=refs/heads/development',
html_url:'https://github.com/sapo/fd1/blob/refs/heads/development/build/.htaccess',
git_url: 'https://api.github.com/repos/sapo/fd1/git/blobs/someSha',
download_url:'https://raw.githubusercontent.com/sameRepo/fd1/refs/heads/development/build/.htaccess?token=someToken',
type: 'file' }
]
Problem/Issue
每当我尝试直接在浏览器中访问任何 url - html_url
、git_url
、download_url
- 我都会收到 404 not found
错误。
我想要实现的目标:
我需要能够将 link 传递给 S3.upload 方法。所以基本上,将这些文件复制到 S3 存储桶。
问题
你能解释一下为什么我会收到 404 错误吗?另外,关于如何使用 url 下载文件内容的任何想法?感谢我能得到的任何指示。
谢谢。
Whenever I attempt to access any the urls' directly in the browser - html_url, git_url, download_url - I get a 404 not found error.
因为我无法访问 https://github.com/sapo/fd1,我想它是一个私有存储库。
见Why am I getting a 404 error on a repository that exists?
To troubleshoot, ensure you're authenticating correctly, your OAuth access token has the required scopes, and third-party application restrictions are not blocking access.