+
95
-

如何使用api接口上传静态资源到Github并且能访问?

如何使用api接口上传静态资源到Github并且能访问?

网友回复

+
15
-

打开网址:https://github.com/settings/tokens

点击生成新的token

800_auto

800_auto

输入名字,选择不过期,然后勾选repo

800_auto

800_auto

复制token,新建一个repo,例如bfw/test

800_auto

<!DOCTYPE html>
<html>
<head>
  <title>GitHub API File Upload</title>
</head>
<body>

<input type="file" id="fileInput" />
<button id="uploadButton">Upload</button>

<script>
document.getElementById('uploadButton').addEventListener('click', async () => {
  const token = '';//换成你自己的

  const repo = 'bfw/test';//换成你自己的
  

  const fileInput = document.getElementById('fileInput');
  
  const file = fileInput.files[0];
  if (!file) {
    ale...

点击查看剩余70%

我知道答案,我要回答