Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support directly access data/public/* contents via URL link #8593

Closed
HowcanoeWang opened this issue Jun 22, 2023 · 2 comments
Closed

Support directly access data/public/* contents via URL link #8593

HowcanoeWang opened this issue Jun 22, 2023 · 2 comments
Assignees
Milestone

Comments

@HowcanoeWang
Copy link

HowcanoeWang commented Jun 22, 2023

In what scenarios do you need this feature?

当开发插件时,需要能通过URL直接访问插件数据下缓存的图片文件。经测试,把图片存在plugin文件夹、widgets文件夹,都可以通过URL相对路径链接直接访问,但是存在storage文件夹下,会报404错误

  • url('/plugin/xxxx/image.png') (成功访问)
  • url('/widgets/xxxx/image.png') (成功访问)
  • url('/storage/xxxx/image.png') (404报错)

怀疑是没有挂载到数据下造成的 (对应代码),或者有别的安全角度的考虑在这里?(那如果只挂载/storage/petal呢?)

image

Describe the optimal solution

其实可以通过思源的readfile API来读取图片的数据然后转成base64字符串的方式实现访问storage目录下的图片,但是感觉绕了一大圈,不如支持挂载storage来的直观

之前也尝试过用Plugin.saveData和Plugin.loadData来读写图片,但是好像只支持标准的json格式,读图片会遇到编码问题

或者提供一个让插件挂载自身/storage/petal/xxxx/文件目录的API?如Plugin.serveStorage()这种,方便通过URL直接访问缓存的文件

Describe the candidate solution

No response

Other information

No response

@88250
Copy link
Member

88250 commented Jun 22, 2023

整个 data/storage/* 都不鉴权的话不安全,我在考虑是 data/storage/public/ 好还是 data/public/ 好,好像后者更好一些。

@88250 88250 self-assigned this Jun 22, 2023
@88250 88250 changed the title Support directly access 'data/storage/*' contents via URL link Support directly access 'data/public/*' contents via URL link Jun 22, 2023
@88250 88250 added this to the 2.9.3 milestone Jun 22, 2023
@88250 88250 changed the title Support directly access 'data/public/*' contents via URL link Support directly access data/public/* contents via URL link Jun 22, 2023
@88250
Copy link
Member

88250 commented Jun 22, 2023

访问路径 /public,比如 http://127.0.0.1:6806/public/1.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants