Notes

GitHub图床配置

image-20220402010103656

  • *设定仓库名:Hsuey/Img
  • *设定分支名:main

    • image-20220402010618294
  • *设定Token:从GitHub上获取tokens

    • image-20220402010944932
  • 指定存储路径:blogImg/
  • 设定自定义域名:https://cdn.jsdelivr.net/gh/Hsuey/Img@main

    • 国内加速访问Github图片,链接格式:https://cdn.jsdelivr.net/gh/[仓库名]@[分支名],基本不影响访问速度
    • 其中gh表示GitHub

常见错误:StatusCodeError: 401 and StatusCodeError: 422

StatusCodeError: 401

------Error Stack Begin------
StatusCodeError: 401 - {"message":"Bad credentials","documentation_url":"https://docs.github.com/rest"}
    at new StatusCodeError (P:\PicGo\resources\app.asar\node_modules\request-promise-core\lib\errors.js:32:15)
    at Request.plumbing.callback (P:\PicGo\resources\app.asar\node_modules\request-promise-core\lib\plumbing.js:104:33)
    at Request.RP$callback [as _callback] (P:\PicGo\resources\app.asar\node_modules\request-promise-core\lib\plumbing.js:46:31)
    at Request.self.callback (P:\PicGo\resources\app.asar\node_modules\request\request.js:185:22)
    at Request.emit (events.js:200:13)
    at Request.<anonymous> (P:\PicGo\resources\app.asar\node_modules\request\request.js:1154:10)
    at Request.emit (events.js:200:13)
    at IncomingMessage.<anonymous> (P:\PicGo\resources\app.asar\node_modules\request\request.js:1076:12)
    at Object.onceWrapper (events.js:288:20)
    at IncomingMessage.emit (events.js:205:15)
-------Error Stack End------- 

出现这个问题的常见原因:

  • 前面获取GitHub的token时的有效期设置的过短,token过期了(GitHub默认有效期是30天,需要自己去改)
  • GitHub图床设置有误
  • 其他玄学……

StatusCodeError: 422

------Error Stack Begin------
StatusCodeError: 422 - {"message":"Invalid request.\n\n\"sha\" wasn't supplied.","documentation_url":"https://docs.github.com/rest/reference/repos#create-or-update-file-contents"}
    at new StatusCodeError (P:\PicGo\resources\app.asar\node_modules\request-promise-core\lib\errors.js:32:15)
    at Request.plumbing.callback (P:\PicGo\resources\app.asar\node_modules\request-promise-core\lib\plumbing.js:104:33)
    at Request.RP$callback [as _callback] (P:\PicGo\resources\app.asar\node_modules\request-promise-core\lib\plumbing.js:46:31)
    at Request.self.callback (P:\PicGo\resources\app.asar\node_modules\request\request.js:185:22)
    at Request.emit (events.js:200:13)
    at Request.<anonymous> (P:\PicGo\resources\app.asar\node_modules\request\request.js:1154:10)
    at Request.emit (events.js:200:13)
    at IncomingMessage.<anonymous> (P:\PicGo\resources\app.asar\node_modules\request\request.js:1076:12)
    at Object.onceWrapper (events.js:288:20)
    at IncomingMessage.emit (events.js:205:15)
-------Error Stack End------- 

这个问题的原因是:上传的图片名称出现重名

  • 最开始用GitHub图床如果出现重名,上传时会自动重命名的,如:img-01.png, img-02.png……;后面突然不行了,不知道这是怎么回事……
  • 解决办法:PicGo设置为时间戳重命名:

    • image-20220402011831083
This is just a placeholder img.