nodejs通过api上传文件到github的repo上代码

代码语言:nodejs

所属分类:上传

代码描述:nodejs通过api上传文件到github的repo上代码

代码标签: nodejs api 上传 文件 github repo 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

const axios = require('axios');
const fs = require('fs');

const token = ''; // 替换为您的 GitHub 访问令牌
const repoOwner = ''; // 替换为仓库所有者的用户名或组织名
const repoName = ''; // 替换为仓库名称
const filePath = '/data/wwwroot/default/rtest.png'; // 替换为要上传的文件路径
const filename = 'rtest.png'; // 替换为要上传到github的文件名

const uploadFile = async () => {
  try {
    const fileContent = fs.readFileSync(filePath);

    const response = await axios.put(`https://api.github.com/repos/${repoOwner}/${repoName}/contents/.........完整代码请登录后点击上方下载按钮下载查看

网友评论0

相似代码