关于 DreamCat

主题名称:DreamCat | 版本:3.0.240224

主题开发:HanFengA7 | CornWorld

Designed by HanFengA7 Power by Typecho

Copyright © 2015-2024 by LychApe All rights reserved!

menu
refresh

调试PicGo插件解决Typora的图片自动上传

作者: ciaoℒy

时间:

调试PicGo插件

图床上传不了图片了, 很奇怪啊. 打开PicGo看看到底是咋回事.

先设置一下代理, 用Burpsuite抓包试试. burpsuite抓不到任何数据包.

image-20220730162048390

有点奇怪. 打开日志看看, 有意义的日志就是这样子的了:

[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
image-20220730163741714 image-20220730164257011
image-20220730163749384 image-20220730163759222
image-20220730163801472

最后在日志中打印出来:

[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判断再说吧

image-20220730170208180

再次测试, 一切都正常了.

[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] 

遗留了两个坑:

  1. 证书明明没有过期, 为什么Nodejs会返回CERT_HAS_EXPIRED same issue
  2. 使用Java(Burpsuite的repeat)和C#(PowerShell)构造的请求, 为什么会返回The filetype you are attempting to upload is not allowed.?

#本文链接:https://blog.chaol.top/archives/58.html
#本文采用 CC BY-NC-SA 4.0 协议进行许可
#如无特别声明,该文章均为 ciaoℒy 原创,转载请遵循 署名-非商业性使用 4.0 国际(CC BY-NC 4.0)协议,即转载请注明文章来源。
#最后编辑时间为: 2022 年 10 月 30 日
none

create 添加新评论


account_circle
email
language
textsms



加我的QQ
加我的微博
加我的支付宝
加我的微信