[GH-ISSUE #593] [bug] Picgo 远程服务器上传图片,读取图片资源问题 #435

Closed
opened 2026-03-02 03:39:51 +03:00 by kerem · 10 comments
Owner

Originally created by @longyq20 on GitHub (Aug 31, 2025).
Original GitHub issue: https://github.com/codexu/note-gen/issues/593

详细描述这个 Bug

在远程服务器上搭建了picgo上传服务并配置了跨域访问。
上传图片是提示跨域问题,检查picgo后端日志,报错如下

startup
[PicList Server] is listening at 36677
[PicList Server] get the request {"list":["/Users/username/Library/Application Support/com.codexu.NoteGen/picgo/58220ab2-73fc-489a-84f4-0fe557b23176.png"]}
[PicList Server] upload files in list
[PicList INFO]: Before transform
[PicList INFO]: Transforming... Current transformer is [path][PicList ERROR]: read file /Users/username/Library/Application Support/com.codexu.NoteGen/picgo/58220ab2-73fc-489a-84f4-0fe557b23176.png error
[PicList INFO]: Before upload
[PicList INFO]: Uploading... Current uploader is [aws-s3-plist][PicList SUCCESS]: 
[PicList Server] upload result
 

查看app上传图片的代码
发现貌似是直接把图片路径传进去了,导致在远程服务器上无法读取。

在终端使用上传命令,能够正常上传并返回图片链接 curl -X POST "https://host/upload" \ -F "image=@/path_to_pic.png"

 try {
    const response = await fetch(`${picgoSetting.url}/upload`, {
      method: 'POST',
      body: JSON.stringify(body)
    })
    const data = await response.json()
    if (data.success) {
      return data.result[0]
    }
    return null

NoteGen 版本

v0.20.2

操作系统

macOS

报错日志

No response

Originally created by @longyq20 on GitHub (Aug 31, 2025). Original GitHub issue: https://github.com/codexu/note-gen/issues/593 ### 详细描述这个 Bug 在远程服务器上搭建了picgo上传服务并配置了跨域访问。 上传图片是提示跨域问题,检查picgo后端日志,报错如下 ```text startup [PicList Server] is listening at 36677 [PicList Server] get the request {"list":["/Users/username/Library/Application Support/com.codexu.NoteGen/picgo/58220ab2-73fc-489a-84f4-0fe557b23176.png"]} [PicList Server] upload files in list [PicList INFO]: Before transform [PicList INFO]: Transforming... Current transformer is [path][PicList ERROR]: read file /Users/username/Library/Application Support/com.codexu.NoteGen/picgo/58220ab2-73fc-489a-84f4-0fe557b23176.png error [PicList INFO]: Before upload [PicList INFO]: Uploading... Current uploader is [aws-s3-plist][PicList SUCCESS]: [PicList Server] upload result ``` 查看app上传图片的[代码]( https://github.com/codexu/note-gen/blob/1a488b614c5856a54f2fe953631cec489429104f/src/lib/imageHosting/picgo.ts#L33) 发现貌似是直接把图片路径传进去了,导致在远程服务器上无法读取。 在终端使用上传命令,能够正常上传并返回图片链接 `curl -X POST "https://host/upload" \ -F "image=@/path_to_pic.png"` ``` try { const response = await fetch(`${picgoSetting.url}/upload`, { method: 'POST', body: JSON.stringify(body) }) const data = await response.json() if (data.success) { return data.result[0] } return null ``` ### NoteGen 版本 v0.20.2 ### 操作系统 macOS ### 报错日志 _No response_
kerem closed this issue 2026-03-02 03:39:52 +03:00
Author
Owner

@codexu commented on GitHub (Sep 4, 2025):

PicGo 中调用只能传递路径
https://picgo.github.io/PicGo-Doc/zh/guide/advance.html#http%E8%B0%83%E7%94%A8%E4%B8%8A%E4%BC%A0%E5%85%B7%E4%BD%93%E8%B7%AF%E5%BE%84%E5%9B%BE%E7%89%87
你查看一下 /Users/username/Library/Application Support/com.codexu.NoteGen/picgo/58220ab2-73fc-489a-84f4-0fe557b23176.png 是否存在这张图片?

<!-- gh-comment-id:3252105680 --> @codexu commented on GitHub (Sep 4, 2025): PicGo 中调用只能传递路径 https://picgo.github.io/PicGo-Doc/zh/guide/advance.html#http%E8%B0%83%E7%94%A8%E4%B8%8A%E4%BC%A0%E5%85%B7%E4%BD%93%E8%B7%AF%E5%BE%84%E5%9B%BE%E7%89%87 你查看一下 /Users/username/Library/Application Support/com.codexu.NoteGen/picgo/58220ab2-73fc-489a-84f4-0fe557b23176.png 是否存在这张图片?
Author
Owner

@longyq20 commented on GitHub (Sep 4, 2025):

PicGo 中调用只能传递路径 https://picgo.github.io/PicGo-Doc/zh/guide/advance.html#http%E8%B0%83%E7%94%A8%E4%B8%8A%E4%BC%A0%E5%85%B7%E4%BD%93%E8%B7%AF%E5%BE%84%E5%9B%BE%E7%89%87 你查看一下 /Users/username/Library/Application Support/com.codexu.NoteGen/picgo/58220ab2-73fc-489a-84f4-0fe557b23176.png 是否存在这张图片?

没有这张图,手动mv进去也没用

<!-- gh-comment-id:3252111469 --> @longyq20 commented on GitHub (Sep 4, 2025): > PicGo 中调用只能传递路径 https://picgo.github.io/PicGo-Doc/zh/guide/advance.html#http%E8%B0%83%E7%94%A8%E4%B8%8A%E4%BC%A0%E5%85%B7%E4%BD%93%E8%B7%AF%E5%BE%84%E5%9B%BE%E7%89%87 你查看一下 /Users/username/Library/Application Support/com.codexu.NoteGen/picgo/58220ab2-73fc-489a-84f4-0fe557b23176.png 是否存在这张图片? 没有这张图,手动mv进去也没用
Author
Owner

@longyq20 commented on GitHub (Sep 4, 2025):

PicGo 中调用只能传递路径 https://picgo.github.io/PicGo-Doc/zh/guide/advance.html#http%E8%B0%83%E7%94%A8%E4%B8%8A%E4%BC%A0%E5%85%B7%E4%BD%93%E8%B7%AF%E5%BE%84%E5%9B%BE%E7%89%87 你查看一下 /Users/username/Library/Application Support/com.codexu.NoteGen/picgo/58220ab2-73fc-489a-84f4-0fe557b23176.png 是否存在这张图片?

没有这张图,手动mv进去也没用

我理解远程部署,即便路径下文件存在,部署picgo的机器也访问不到,那或许应该用类似命令行的表单上传?curl -X POST "https://host/upload" \ -F "image=@/path_to_pic.png"这样是可以的

<!-- gh-comment-id:3252119437 --> @longyq20 commented on GitHub (Sep 4, 2025): > > PicGo 中调用只能传递路径 https://picgo.github.io/PicGo-Doc/zh/guide/advance.html#http%E8%B0%83%E7%94%A8%E4%B8%8A%E4%BC%A0%E5%85%B7%E4%BD%93%E8%B7%AF%E5%BE%84%E5%9B%BE%E7%89%87 你查看一下 /Users/username/Library/Application Support/com.codexu.NoteGen/picgo/58220ab2-73fc-489a-84f4-0fe557b23176.png 是否存在这张图片? > > 没有这张图,手动mv进去也没用 我理解远程部署,即便路径下文件存在,部署picgo的机器也访问不到,那或许应该用类似命令行的表单上传?`curl -X POST "https://host/upload" \ -F "image=@/path_to_pic.png"`这样是可以的
Author
Owner

@codexu commented on GitHub (Sep 4, 2025):

我这边使用 PicGo 是正常的,/Users/username/Library/Application Support/com.codexu.NoteGen/picgo/ 是临时创建的,其中的图片在上传后会删除,你是通过什么才做进行上传图片的?在markdown编辑器中还是插图记录?

<!-- gh-comment-id:3252125419 --> @codexu commented on GitHub (Sep 4, 2025): 我这边使用 PicGo 是正常的,/Users/username/Library/Application Support/com.codexu.NoteGen/picgo/ 是临时创建的,其中的图片在上传后会删除,你是通过什么才做进行上传图片的?在markdown编辑器中还是插图记录?
Author
Owner

@codexu commented on GitHub (Sep 4, 2025):

另外查看一下 PicGo 是否正确?

Image
<!-- gh-comment-id:3252129995 --> @codexu commented on GitHub (Sep 4, 2025): 另外查看一下 PicGo 是否正确? <img width="808" height="180" alt="Image" src="https://github.com/user-attachments/assets/95a7ece6-e48a-405a-a46d-791206ced101" />
Author
Owner

@longyq20 commented on GitHub (Sep 4, 2025):

我这边使用 PicGo 是正常的,/Users/username/Library/Application Support/com.codexu.NoteGen/picgo/ 是临时创建的,其中的图片在上传后会删除,你是通过什么才做进行上传图片的?在markdown编辑器中还是插图记录?

在markdown编辑器中粘贴图片

<!-- gh-comment-id:3252130634 --> @longyq20 commented on GitHub (Sep 4, 2025): > 我这边使用 PicGo 是正常的,/Users/username/Library/Application Support/com.codexu.NoteGen/picgo/ 是临时创建的,其中的图片在上传后会删除,你是通过什么才做进行上传图片的?在markdown编辑器中还是插图记录? 在markdown编辑器中粘贴图片
Author
Owner

@codexu commented on GitHub (Sep 4, 2025):

我这边的确是可以正常上传,你检查一下是否是你图床有问题?
https://github.com/user-attachments/assets/84266f9f-59b8-4132-aa77-bd38d51bcc35

<!-- gh-comment-id:3252142377 --> @codexu commented on GitHub (Sep 4, 2025): 我这边的确是可以正常上传,你检查一下是否是你图床有问题? https://github.com/user-attachments/assets/84266f9f-59b8-4132-aa77-bd38d51bcc35
Author
Owner

@longyq20 commented on GitHub (Sep 4, 2025):

我这边的确是可以正常上传,你检查一下是否是你图床有问题? https://github.com/user-attachments/assets/84266f9f-59b8-4132-aa77-bd38d51bcc35

嗯,我再试下部署picgo 官方的包。现在用的是piclist-core docker部署

<!-- gh-comment-id:3252148002 --> @longyq20 commented on GitHub (Sep 4, 2025): > 我这边的确是可以正常上传,你检查一下是否是你图床有问题? https://github.com/user-attachments/assets/84266f9f-59b8-4132-aa77-bd38d51bcc35 嗯,我再试下部署picgo 官方的包。现在用的是piclist-core docker部署
Author
Owner

@codexu commented on GitHub (Sep 4, 2025):

#581 提出了使用命令上传图片的方案,这块后续考虑支持一下。

<!-- gh-comment-id:3252159467 --> @codexu commented on GitHub (Sep 4, 2025): #581 提出了使用命令上传图片的方案,这块后续考虑支持一下。
Author
Owner

@longyq20 commented on GitHub (Sep 4, 2025):

#581 提出了使用命令上传图片的方案,这块后续考虑支持一下。

<!-- gh-comment-id:3252166293 --> @longyq20 commented on GitHub (Sep 4, 2025): > [#581](https://github.com/codexu/note-gen/issues/581) 提出了使用命令上传图片的方案,这块后续考虑支持一下。
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/note-gen#435
No description provided.