@filebox/core
v1.0.12
Published
filebox-core
Readme
@filebox/core
FileBox 的虚拟文件系统核心包,用来把不同存储驱动挂载到统一的路径空间里,并通过同一套 API 读写文件。
安装
pnpm add @filebox/core使用
import FileBox from "@filebox/core";
import WebDAVDriver from "./drivers/webdav";
FileBox.use({
name: "webdav",
package: WebDAVDriver,
});
const filebox = new FileBox();
await filebox.mount({
name: "/dav",
provider: "webdav",
rootPath: "/",
auth: {
url: "https://example.com/dav/",
username: "user",
password: "password",
},
});
const list = await filebox.list("/dav");
const stat = await filebox.stat("/dav/readme.txt");常用 API:
mount(options):挂载一个驱动到指定路径。unmount(path):卸载已挂载的路径。list(path):读取目录。stat(path):读取文件或目录信息。mkdir(path, name)、upload(path, file)、remove(path)、rename(path, name):常见文件操作。
License
MIT
