ReboFiles文档
开始3
什么是 ReboFiles
快速开始
可运行的演示
集成到你的应用6
React 组件
Headless:你自己的界面
不使用框架
样式与主题
键盘与无障碍
语言
文件9
上传
预览与查看器
搜索
实时更改与大文件夹
评论
星标与字段
版本、回收站与空间
打包下载 .zip
Word 文档
服务器14
路由
框架与登录
谁可以做什么
存储:S3、GCS、Azure 与磁盘
检查上传
元数据:SQLite 与 Postgres
数据库结构
共享与链接
动态与通知
钩子、日志与限制
保留、法律保留与导出
桌面端与其他来源
同步文件夹
上线生产环境
协作1
AI 助手(MCP)
参考5
包
组件与 hooks
客户端 API
HTTP 路由
状态与路线图
↑↓ 移动↵ 打开Esc 关闭38 个页面

集成到你的应用 不使用框架

不使用框架

<FileDrive> 挂载的其实是 @rebofiles/drive,它不需要任何框架:Vue、Svelte、Angular 或纯 HTML 页面都可以。它接受相同的选项,重新渲染时只更新变化的部分,因此焦点和滚动位置都保持不变。
开始

挂载

import { mountDrive, mountSharedLink } from '@rebofiles/drive';
import { pictureOfDocx, previewDocx, textOfDocx, thumbDocx, viewDocx } from '@rebofiles/drive/rebodocs';

const drive = mountDrive(document.getElementById('files')!, {
  base: '/api/files',
  theme: 'auto',
  previewDocument: previewDocx,
  viewDocument: viewDocx,
  thumbDocument: thumbDocx,
  pictureDocument: pictureOfDocx,
  textDocument: textOfDocx,
  onChange: () => refreshTheRestOfThePage(),
});

drive.update({ language: 'es' });  // other options, as a framework gives them again
drive.refresh();                   // after a change made elsewhere
drive.destroy();

// What someone sent a link sees:
mountSharedLink(document.getElementById('shared')!, { token: new URLSearchParams(location.search).get('link')! });
组成

底层的各个部分

每个部分都已导出,可用来构建不依赖 React 的自定义界面。

名称作用
createDriveClient服务器的每条路由对应一个函数;支持续传的分片上传。
createUploads上传队列:同时三个、速度、剩余时间,以及对已存在文件的询问。
lookInDrive上传前在网盘中查找文件。
readDropped, readChosen拖放或选择的文件夹中的文件及其路径。
downloadZip, writeZip在页面中边下载边生成 .zip。
renditionsOf, placeholderOf图片的缩小版本及其占位图。
textOf, hashOf文件中的文字及其 SHA-256。
CSS, TEXTS, translator限定在 .rf-drive 范围内的样式,以及文字。
import { createDriveClient, createUploads, formatDuration, lookInDrive } from '@rebofiles/drive';

const client = createDriveClient({ base: '/api/files' });
const uploads = createUploads(client, { check: lookInDrive(client), onChange: draw });
uploads.add(input.files, folderId);
// uploads.items, uploads.summary(): what to draw; stop, retry, decide, dismiss, clear