PicGo-core安装web-uploader插件
1. Typora启用picgo
文件-偏好设置-图像-上传服务设定-PicGo-core(command line)
2. 安装插件
打开路径C:\Users\你的用户名.picgo(其他环境自己百度吧,我这是Windows),然后输入命令(得确保PC已有Node环境,不然npm报没有命令):
npm install picgo-plugin-web-uploader
安装插件picgo-plugin-web-uploader
3. 配置插件
打开picgo的目录,在 Typora 中安装的 PicGo-Core 通常会被安装在以下目录中:
- Windows:%APPDATA%\Typora\picgo\
- macOS:~/Library/Application Support/abnerworks.Typora/picgo/
Linux:~/.config/Typora/picgo/
然后输入picgo.exe set uploader,这个时候就可以填配置信息了:C:\Users\user\AppData\Roaming\Typora\picgo\win64>picgo.exe set uploader > Choose a(n) uploader web-uploader > API地址 http://xfstu.com/test > POST参数名 file > 图片URL JSON路径(eg: data.url) data.url.url > 自定义请求头 标准JSON(eg: {"key":"value"}) > 自定义Body 标准JSON(eg: {"key":"value"}) [PicGo SUCCESS]: Configure config successfully!
其中json路径这个根据自己的实际情况来配置。根据我的json结构,应该填data.url.url。然后检查一下第二步中的config.json的current字段是不是插件名字,即web-uploader
4. 检查配置是否正确
编辑配置文件:C:\Users\用户.picgo\config.json
自己根据需求填写,这里注意以下标准JSON需要中的key和value均需要使用反斜杠\,转义。
url: 图床上传API地址
paramName: POST参数名
jsonPath: 图片URL所在返回值的JsonPath(eg:data.url)
customHeader: 自定义请求头 标准JSON(eg: {“key”:“value”}
customBody: 自定义Body 标准JSON(eg: {“key”:“value”})
建议加入请求头。因为当你的 cloudflare的防火墙设置了用户代理后,可能会阻止。
{
"picBed": {
"current": "web-uploader",
"web-uploader": {
"url": "xxxxxxxxxxx",
"paramName": "xxxxxx",
"jsonPath": "url",
"customHeader": "",
"customBody": "{\"token\":\"xxxxxxxxxxxxxxxxxxxxxx\"}"
}
},
"picgoPlugins": {
"picgo-plugin-web-uploader": true
}
}