Skip to content

Latest commit

 

History

History
80 lines (49 loc) · 1.8 KB

README-zh_CN.md

File metadata and controls

80 lines (49 loc) · 1.8 KB

vfs-frontend

vfs-frontend 是一个纯前端实现的简易虚拟文件系统,只需传递带有 zip 属性的 blob 二进制数据即可在前端构建出一个虚拟文件系统,解析 blob 数据用的是 JSZip 这个库

English | 简体中文

demo

https://ricbet.github.io/vfs-frontend/

安装

yarn add vfs-frontend

如何使用

const vfsService = new ZipVFSService();

// 仅接收 blob 数据
vfsService.mount(blob).then(async () => {
    // do it
});

此时 vfsService 已经被挂载了, 例如

mount

根目录默认为 '/', 你可以使用 ls 方法查看某个目录下的所有文件, 例如

vfsService.ls('/').then((data: Inode[]) => {
    // do it
})

ls

🌈enjoy😊🌈

API

interface IVfsable<T> {
    mount(
        data: T,
        options?: {
            name: string;
        }
    ): Promise<never>;

    ls(path: string): Promise<Inode[]>;

    read(path: string, encode?: string): Promise<string | Error>;

    mkdir(path: string): Promise<Inode | Error>;

    touch(path: string): Promise<Inode | Error>;

    write(path: string, options: { isAppend: boolean }, content: string): Promise<never | Error>;

    exist(path: string): Promise<boolean>;

    cp(source: string, copyend: string): Promise<never | Error>;

    mv(source: string, target: string): Promise<never | Error>;

    rm(path: string, options: { isForce: boolean; isRecursive: boolean }): Promise<never | Error>;

    isMount: () => boolean;

    getBlob: () => Promise<Blob>;
}

LICENSE

MIT