Skip to content

[开发帮助] 希望支持下载用户发送的文件消息 / Request support for downloading user-sent file messages #133

Description

@mycopilot2023

问题描述

问题描述

您好,感谢维护这个插件项目和相关开发文档。目前在 PluginMsgMethod.md 中已经提供了类似 downloadImg(...) 的图片下载方法,可以方便地把用户发送的图片保存到本地路径。

我在开发插件时遇到一个需求:希望能够下载用户在聊天中发送过来的普通文件,例如 .md.txt.zip.pdf 等文件消息。当前这类消息在 XML 中可以看到文件名、文件大小、扩展名、fileuploadtokenmd5 等信息,例如:

<msg>
    <appmsg appid="" sdkver="0">
        <title>
            <![CDATA[test.md]]>
        </title>
        <type>74</type>
        <showtype>0</showtype>
        <appattach>
            <totallen>9037</totallen>
            <fileext>
                <![CDATA[md]]>
            </fileext>
            <fileuploadtoken>v1_/6z9eZEGxxxxxxxPHths=</fileuploadtoken>
            <status>0</status>
            <cdnthumburl>
                <![CDATA[]]>
            </cdnthumburl>
            <cdnthumbmd5>
                <![CDATA[]]>
            </cdnthumbmd5>
            <cdnthumbaeskey>
                <![CDATA[]]>
            </cdnthumbaeskey>
            <cdnthumblength>0</cdnthumblength>
            <cdnthumbheight>0</cdnthumbheight>
            <cdnthumbwidth>0</cdnthumbwidth>
        </appattach>
        <md5>
            <![CDATA[xxxxxx]]>
        </md5>
        <laninfo>
            <![CDATA[]]>
        </laninfo>
    </appmsg>
    <fromusername>xxxxxx</fromusername>
</msg>

但目前我还没有找到类似“下载文件”的插件 API。希望后续是否可以考虑增加一个类似下载图片的接口,例如:

void downloadFile(String fileIdOrToken, String md5, String savePath);

void downloadFile(MsgInfoBean.FileMsg fileMsg, String savePath);

或者如果现有 API 已经能够实现,也希望能在文档中补充一个最小示例,说明如何从 msgInfoBean 中识别用户发送的文件消息,并将文件保存到本地路径,例如 cacheDir + "/test.md"

这个能力对开发自动归档、文件转发、文件内容解析、文件备份类插件会非常有帮助。辛苦维护者有空时看一下,非常感谢!


Hello, and thank you for maintaining this plugin project and its developer documentation. I noticed that PluginMsgMethod.md already provides image download APIs such as downloadImg(...), which make it convenient to save user-sent images to a local path.

I am currently developing a plugin and would like to download normal files sent by users in chat, such as .md, .txt, .zip, .pdf, and similar file messages. From the message XML, I can see fields such as filename, file size, extension, fileuploadtoken, and md5, for example:

<msg>
    <appmsg appid="" sdkver="0">
        <title>
            <![CDATA[test.md]]>
        </title>
        <type>74</type>
        <showtype>0</showtype>
        <appattach>
            <totallen>9037</totallen>
            <fileext>
                <![CDATA[md]]>
            </fileext>
            <fileuploadtoken>v1_/6z9eZEGxxxxxxxPHths=</fileuploadtoken>
            <status>0</status>
            <cdnthumburl>
                <![CDATA[]]>
            </cdnthumburl>
            <cdnthumbmd5>
                <![CDATA[]]>
            </cdnthumbmd5>
            <cdnthumbaeskey>
                <![CDATA[]]>
            </cdnthumbaeskey>
            <cdnthumblength>0</cdnthumblength>
            <cdnthumbheight>0</cdnthumbheight>
            <cdnthumbwidth>0</cdnthumbwidth>
        </appattach>
        <md5>
            <![CDATA[xxxxxx]]>
        </md5>
        <laninfo>
            <![CDATA[]]>
        </laninfo>
    </appmsg>
    <fromusername>xxxxxx</fromusername>
</msg>

However, I could not find a plugin API similar to “download file”. Would it be possible to add a file download method similar to the existing image download API, for example:

void downloadFile(String fileIdOrToken, String md5, String savePath);

void downloadFile(MsgInfoBean.FileMsg fileMsg, String savePath);

Alternatively, if this is already possible with the existing APIs, it would be very helpful if the documentation could include a minimal example showing how to detect a user-sent file message from msgInfoBean and save it to a local path such as cacheDir + "/test.md".

This feature would be very useful for plugins that need automatic file archiving, file forwarding, file content parsing, or file backup. Thank you very much for your time and effort!

其他要求

  • 我在 Issue 没有发现相同问题
  • 我已知晓不按照模板提供的指示进行填写, 则我的 Issue 可能会被无条件删除

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions