Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
有没有办法使用GithubAPI将文件夹上载到github存储库_Github_Github Api - Fatal编程技术网

有没有办法使用GithubAPI将文件夹上载到github存储库

有没有办法使用GithubAPI将文件夹上载到github存储库,github,github-api,Github,Github Api,根据文档,有一种方法只能从GitHub API上传文件 await octokit.request('PUT /repos/{owner}/{repo}/contents/{path}', { owner: 'octocat', repo: 'hello-world', path: 'path', message: 'message', content: 'base64 content' }) 但是我想从GithubAPI上传一个文件夹。由于文件夹无法编码到base64(或

根据文档,有一种方法只能从GitHub API上传文件

await octokit.request('PUT /repos/{owner}/{repo}/contents/{path}', {
  owner: 'octocat',
  repo: 'hello-world',
  path: 'path',
  message: 'message',
  content: 'base64 content'
})
但是我想从GithubAPI上传一个文件夹。由于文件夹无法编码到base64(或者有任何方法吗?),而且我不想上载zip文件,有没有方法使用github API上载文件夹?

一种解决方法(不上载zip文件)可以是使用and在新文件夹中创建一个文件,因为
git
只跟踪其中包含文件的文件夹


示例

假设我们有一个用户拥有包含以下内容的回购协议:

├── LICENSE
├── main.py
├── main_test.py
└── README.md
如果我们想在
examples
文件夹中创建名为
example.py
的文件,我们将发出以下请求:

PUT/repos///contents/examples/example.go

创建新文件请求的模板如下所示:

PUT/repos/:owner/:repo/contents/:path


因此,在您的情况下,您可以使用上面的示例中的请求来创建包含其中一个文件的新文件夹。然后将其他文件添加到文件夹中