picgo-core + typora + github或oss 图床

picgo-core + typora + github或oss 图床

警告
本文最后更新于 2023-04-20,文中内容可能已过时。

picgo-core + typora + github或oss 图床

【Typora】typora+picgo+阿里云oss搭建图床 - sakuraxx - 博客园 (cnblogs.com)

Typora + PicGo-Core + Github 实现图片上传到Github - jxiaow - 博客园 (cnblogs.com)

安装picgo-core

默认拥有npm,没有先用brew安装,没有brew镜像快速安装Homebrew教程安装

1
npm install picgo -g

安装插件

1
picgo install github-plus rename-file # github上传插件,文件改名插件

创建oss仓库或者github仓库

此过程略去可以参考上面的文章

配置文件

一般路径在~/.picgo/config.json这里,但是windows下如果用typora安装则应该是在typora安装路径下进行查找

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{
  "picBed": {
    "uploader": "github", // 选择上传的服务
    "aliyun": {
      "accessKeyId": "", // id
      "accessKeySecret": "", // secret
      "bucket": "raja-img", // bucket
      "area": "oss-cn-hangzhou", // area
      "path": "img/", // 目录
      "customUrl": "https://xxx.oss-cn-hangzhou.aliyuncs.com", // 自定义域名,需要在oss配置
      "options": ""
    },
    "github": {
      "repo": "0RAJA/img", // repo 名,格式為 username/<repo name>
      "token": "", // github token
      "path": "", // 自定義存儲路徑,比如 img/
      "customUrl": "", // 自定義域名,注意要加 http://或者 https://
      "branch": "main" // 分支名,默認是 main
    }
  },
  "picgoPlugins": {
    "picgo-plugin-rename-file": true,
    "picgo-plugin-github-plus": true
  },
  "picgo-plugin-rename-file": {
    "format": "{y}{m}{d}{h}{i}{s}-{ms}-{origin}" // 重命名
  }
}

测试

  1. 终端测试

    picgo upload xxx.img

  2. typora 测试

    image

    需要注意的地方是

    1. 这里需要填写picgo的路径,不然可能找不到命令
    2. 如果出现env node ......node的位置写前面,参考typora 配置picgo-core出现env: node: No such file or directory的解决方法 - vpslala.com