调试PicGo插件
图床上传不了图片了, 很奇怪啊. 打开PicGo看看到底是咋回事.
先设置一下代理, 用Burpsuite抓包试试. burpsuite抓不到任何数据包.
有点奇怪. 打开日志看看, 有意义的日志就是这样子的了:
[PicGo INFO] [PicGo Server] is listening at 36677
[PicGo INFO] Before transform
[PicGo INFO] Transforming... Current transformer is [path]
[PicGo INFO] Before upload
[PicGo INFO] beforeUploadPlugins: renameFn running
[PicGo INFO] Uploading... Current uploader is [web-uploader-custom-url-prefix]
[PicGo SUCCESS]
感觉报错应该是出在上传插件里面. 打开上传插件(picgo-plugin-web-uploader-custom-url-prefix)的源码, 添加几个点, 打印一些日志来调试一下. PicGo的日志打印函数是ctx.log
. 需要重启PicGo才能重新加载代码
1 | 2 |
---|---|
最后在日志中打印出来:
[PicGo INFO] beforeUploadPlugins: renameFn running
[PicGo INFO] Uploading... Current uploader is [web-uploader-custom-url-prefix]
[PicGo INFO] 插件开始
[PicGo INFO] 进入try
[PicGo INFO] imglist的长度是: 1
[PicGo INFO] 准备参数
[PicGo INFO] 开始上传
[PicGo ERROR] 出错了
[PicGo ERROR] {"name":"RequestError","message":"Error: certificate has expired","cause":{"code":"CERT_HAS_EXPIRED"},"error":{"code":"CERT_HAS_EXPIRED"},"options":
哦, 竟然是证书过期了. 但是我的证书没有过期啊🤔先屏蔽掉ssl判断再说吧
再次测试, 一切都正常了.
[PicGo INFO] Uploading... Current uploader is [web-uploader-custom-url-prefix]
[PicGo INFO] 插件开始
[PicGo INFO] 进入try
[PicGo INFO] imglist的长度是: 1
[PicGo INFO] 准备参数
[PicGo INFO] 开始上传
[PicGo INFO] 上传结束, 返回值是: {"code":200,"id":"210","imgid":"2b3d0fba58*****","relative_path":"\/imgs\/2022\/07\/2b3d0fba58*****.png","url":"********"}
[PicGo INFO] 返回的json是: {"code":200,"id":"210","imgid":"2b3d0fba58*****","relative_path":"\/imgs\/2022\/07\/2b3d0fba58*****.png","url":"**********","width":1491,"height":232,"delete":"************"}
2022-07-30 17:07:17 [PicGo SUCCESS]
遗留了两个坑:
- 证书明明没有过期, 为什么Nodejs会返回
CERT_HAS_EXPIRED
same issue - 使用Java(Burpsuite的repeat)和C#(PowerShell)构造的请求, 为什么会返回The filetype you are attempting to upload is not allowed.?