Skip to content

API /asset/upload 使用子文件夹时返回结果不正确 #7454

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

Closed
3 tasks done
KarlKaijie opened this issue Feb 23, 2023 · 0 comments
Closed
3 tasks done

API /asset/upload 使用子文件夹时返回结果不正确 #7454

KarlKaijie opened this issue Feb 23, 2023 · 0 comments
Assignees
Labels
Milestone

Comments

@KarlKaijie
Copy link

该问题是否已经被报告过了? Is there an existing issue for this?

  • 我已经搜索了 Issues,没有发现类似问题
    I have searched the existing issues

该问题是否能够在默认主题(daylight/midnight)下重现? Can the issue be reproduced with the default theme (daylight/midnight)?

  • 我能够在默认主题下重现该问题
    I was able to reproduce the issue with the default theme

该问题是否可能是由于扩展功能导致? Could the issue be due to extensions?

  • 我已经排除了扩展导致问题的可能性
    I've ruled out the possibility that the extension is causing the problem.

描述问题 Describe the problem

最近在写挂件的时候调用Upload接口,为了不把文件都放在assets的第一层级,显得凌乱,需要把资源文件汇总到一个文件夹, 但是发现个问题

接口 /api/asset/upload 上传文件
参数: 
assetsDirPath: "/assets/folderName/"

成功创建文件夹,并且文件也上传成功_,但是接口返回的路径,并不包含 folderName, 因此导致无法直接使用返回的路径存到挂件的自定义属性上,只能自己拼接地址。

返回值如下:
{
    "code": 0,
    "msg": "",
    "data": {
        "errFiles": null,
        "succMap": {
            "111.html": "assets/111-20230223092555-ab7pit7.html"
        }
    }
}

API文档提及的 assetsDirPath: /Test Notebook/assets/ 存在同样问题

期待的结果 Expected result

  1. 改动的话,建议/api/asset/upload 返回地址包含 多级文件夹
  2. 不改动的话,建议更新下API文档,以及issue 1488下面这段描述,以免引起歧义
如果有大量数据需要存储,建议将这些数据通过[上传资源文件 API](https://github.com/siyuan-note/siyuan/blob/master/API.md#%E4%B8%8A%E4%BC%A0%E8%B5%84%E6%BA%90%E6%96%87%E4%BB%B6) 上传,然后将返回的资源文件地址通过设置属性接口(属性名使用 data-assets)保存在挂件自身的属性上。使用 data-assets 这个固定的属性名的目的是为了防止清理未引用资源时误删挂件数据文件。

截屏或者录屏演示 Screenshot or screen recording presentation

No response

版本环境 Version environment

- Version: 2.7.6
- Operating System: macos
- Browser (if used):

日志文件 Log file

...

更多信息 More information

No response

@KarlKaijie KarlKaijie changed the title 请输入问题报告标题 Please enter the title of the bug report Upload接口返回信息和预期及API文档描述不一致 Feb 23, 2023
@88250 88250 self-assigned this Feb 23, 2023
@88250 88250 added the Bug label Feb 23, 2023
@88250 88250 added this to the 2.7.7 milestone Feb 23, 2023
@88250 88250 changed the title Upload接口返回信息和预期及API文档描述不一致 API /asset/upload 使用子文件夹时返回结果不正确 Feb 23, 2023
88250 added a commit that referenced this issue Feb 23, 2023

Verified

This commit was signed with the committer’s verified signature.
bagder Daniel Stenberg
@88250 88250 closed this as completed Feb 23, 2023
88250 added a commit that referenced this issue Mar 7, 2023

Verified

This commit was signed with the committer’s verified signature.
bagder Daniel Stenberg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants