A HTTP static file hosting plugin for NoneBot2, which provides an graceful solution for cross-machine file transfer.
Project description
nonebot-plugin-filehost
NoneBot2 的 HTTP 静态文件托管插件,为跨机文件传输提供了优雅的解决方案
优势
-
跨机器, 跨网络支持, 只要反向WebSocket可以正常连接, 它就可以使用
-
使用临时文件作为中转, 内存占用低
- 临时文件会尝试采用硬链接方式创建, 快速且可靠
- 临时文件在程序退出时会自动删除, 不会永久占用空间
-
自动检测访问来源生成资源URL, 无需手动配置
开始使用
安装插件
- 如果使用了
nb-cli
nb plugin install nonebot-plugin-filehost
-
或者手动安装:
-
使用你的包管理器(如
pip
)安装nonebot-plugin-filehost
:pip install nonebot-plugin-filehost
-
修改
pyproject.toml
文件(推荐)[nonebot.plugins] - plugins = [] + plugins = ["nonebot_plugin_filehost"] plugin_dirs = ["src/plugins"]
-
修改
bot.py
文件, 添加一行:driver = nonebot.get_driver() driver.register_adapter("cqhttp", CQHTTPBot) nonebot.load_from_toml("pyproject.toml") + nonebot.load_plugin('nonebot_plugin_filehost')
-
使用插件
- 请前往示例插件进行查看
进行配置
本插件支持以下配置项
-
FILEHOST_FALLBACK_HOST
- 当请求不包含
Host
头或者上下文变量序列化失败时使用的主机地址 - 默认为
None
, 示例值为http://localhost:8080
- 当请求不包含
-
FILEHOST_LINK_FILE
- 使用文件系统链接代替文件复制, 可以提升临时文件创建速度
- 默认为
True
,同时支持bool
和int
类型- 当为
bool
时, 无条件启用链接 - 当为
int
时, 当文件字节数大于或等于该数时启用链接, 低于时使用复制
- 当为
-
FILEHOST_LINK_TYPE
- 指定使用的链接类型, 有
hard
和soft
两个可选值hard
: 建立硬链接soft
: 链接软链接 (符号链接)
- 默认为
hard
- 指定使用的链接类型, 有
开源许可
本项目采用MIT许可
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for nonebot-plugin-filehost-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3cba01ddc19aff949c742bb3bcbb6242ef9e0f6d3705ce573d3365252bde3104 |
|
MD5 | 16c7edddee2e1a2ffbc093e0a229842d |
|
BLAKE2b-256 | 6d74069f1f9a83fd5eac50add06c2462634e70ce307fde7cdb12ff93ba990373 |
Close
Hashes for nonebot_plugin_filehost-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd17cf5fb612d0fb2441d00e1694d67bdb6ccfd5826e479550730275557ad1b7 |
|
MD5 | 0d703dfc919058a30b913e85fd3fb68c |
|
BLAKE2b-256 | cd874ca808e58c4b528982988d953ee0f5909a761ef55f605c74c266d2b9cb29 |