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

服务器 共享与链接

共享与链接

在条目的详情中点击“共享”,即可按你的 identify 提供的 id 把它共享给某人,或共享给所有已登录用户;文件夹中的内容会随之共享。
成员

角色

查看者、评论者或编辑者,作用于条目及其中的内容。它会出现在对方的与我共享中,而不是对方的“我的文件”里——那里只属于他们自己;旁边还会显示自上次查看以来的新内容数量。如果想让整个团队共用一个网盘,请为服务器设置 top: 'everyone'。

链接

任何拥有链接的人都可以查看和下载,无需登录,有效期可设为一天、一周或一个月,或直到被移除。

  • 带密码:在显示任何内容之前先要求输入,每次请求都以 x-link-password 发送,只保存经 scrypt 处理后的结果,每次输错后都会稍作延迟。
  • 仅限一次下载:下载文件或其压缩包时才算使用,仅查看不算;之后的一刻钟内仍然有效,以便完成该次下载中的文件。
// The page a link goes to: app/shared/page.tsx
'use client';
import { SharedLink } from '@rebofiles/react';
import { useSearchParams } from 'next/navigation';

export default function Shared() {
  return <SharedLink base="/api/files" token={useSearchParams().get('link') ?? ''} />;
}

// And in the drive, where its links point:
<FileDrive base="/api/files" linkAddress={(token) => `${origin}/shared?link=${token}`} />
期限

限时共享

与某人共享一天、一周、一个月或三个月:到期后不再授予任何权限,如同已撤销,也不再出现在其“与我共享”中。

await client.share(folder.id, 'auditor', 'viewer', 30);   // for thirty days, then nothing
await client.share(folder.id, 'auditor', 'editor');       // another role: the same end
await client.share(folder.id, 'auditor', 'editor', null); // for good

对话框和详情会显示到期时间;已结束的会标明,可重新共享或删除。

上传

文件收集

在文件夹的菜单中(进入文件夹后在其名称旁)选择“收集文件”:创建可接收文件的链接,“仅发送文件”不显示文件夹中的任何内容,“查看并添加文件”则可查看。创建后自动复制,可直接打开或发送;打开链接的人无需登录,可选填姓名后发送。

// A request for files: whoever opens it sends them, and sees nothing of what is there.
const { token } = await client.createLink(folder.id, 7, {
  uploads: 'only', // or 'also': they see the folder, and may add to it
  request: {
    title: 'Northwind',
    message: 'Send what is missing, please.',
    askName: true,
    email: 'carla@northwind.com',                    // for your app to remind her, and send a receipt
    items: [{ id: 'contract', label: 'Signed contract' }, { id: 'id', label: 'ID' }],
    closeWhenDone: true,                             // closed once both came
    accept: ['application/pdf', 'image/*'],
    maxSize: 25 * 1024 * 1024,
    perSender: true,                                 // Northwind papers / Carla Ruiz / …
    rename: '{item} - {name}',                       // "Signed contract - Carla Ruiz.pdf"
    fields: { client: 'northwind' },                 // found by your CRM with withField
  },
});

createDriveHandler({
  ...options,
  onReceived: ({ entry, from, item, request, got }) => mail(request?.email, `Received: ${item}`),
  onReview: ({ entry, status, reason, from }) => status === 'rejected' && tellToSendAgain(from, reason),
});
// A cron of yours: GET /admin/requests gives every request open, whom it was sent to and what is missing.
  • 发送者会看到所需的每份文件各自的位置,可“选择文件”或“拍照”:同一份文件的多张照片会合并为一个 PDF。发送后十分钟内可撤销,并可下载回执。
  • 收到的文件属于文件夹的所有者,计入其空间,并注明发送者和对应的文件项。所有者会在铃铛中收到通知,在“已收到”中查看全部,并可接受或附原因退回。
  • 文件夹在文件上方显示进行中的收集:每项收到了什么、还缺什么、到期时间。
  • 与其他文件一样分片直接上传到存储,中断后可续传并接受检查;该链接不能做其他任何事。有效期和密码与其他链接相同。
  • 链接页面会显示你的公司名称(设置 → company)和网盘的品牌色,让发送者知道是发给谁的。
文件收集

模板、提醒、检查与到期

文件收集除了接收文件之外还能做的事。除非网盘或服务器设为 false,否则都会开启;提醒需要提供发送方式。

import { createDriveHandler, mailReminders, resend } from '@rebofiles/server';

createDriveHandler({
  ...options,
  // Whom a request was sent to, reminded every `remind` days of what is missing, and with "Remind now".
  reminders: mailReminders({
    mail: resend({ apiKey: process.env.RESEND_KEY!, from: 'Acme <files@acme.com>' }), // or (mail) => yourSmtp(mail)
    url: (token) => `https://files.acme.com/?link=${token}`,
  }),
  // Told 15 days before a file's field `expires`, in the bell and here; `false` for none.
  expiring: { days: 15, onExpiring: ({ entry, expires }) => log(entry.name, expires) },
  // What is written in what came, against its document's words and patterns: the core's, yours, or false.
  // check: async ({ entry, item, text }) => ({ missing: [], fields: await readWithYourService(text) }),
});

await client.createLink(folder.id, 30, {
  uploads: 'only',
  request: {
    email: 'carla@northwind.com',
    remind: 3,
    items: [
      { id: 'id', label: 'ID', words: ['INE', 'passport'], expires: true },
      { id: 'tax', label: 'Tax certificate', find: { rfc: '\\b([A-Z&Ñ]{3,4}\\d{6}[A-Z0-9]{3})\\b' } },
    ],
  },
});

// Templates, for everyone of the drive: saved from the dialog, or given as the defaults.
createDriveHandler({ ...options, settings: { requestTemplates: [{ id: 'supplier', name: 'Supplier sign-up', request }] } });
  • 模板:在请求对话框顶部“从模板开始”;有配置权限的人可“存为模板”(保存要求的内容和方式,不含发给谁)。在“设置 → 外观”中列出,可删除。界面的 requestTemplates: false 可关闭。
  • 链接地址的二维码:在请求创建后的页面中,可给手机扫描或下载为 PNG;qr: false 可关闭。
  • 提醒:只要请求仍开放且有缺失,每 2、3 或 7 天提醒收件人,也可点“立即提醒”。服务器没有 reminders 时,对话框不会提供该选项。
  • 检查:文件应包含的词以及要从中提取的字段,与收到文件中的文字(文本或图片 OCR)比对。都不包含的会在“已收到”中标为“未包含 …”;模糊的照片会在发送前请对方重拍(链接页面的 checkBlur: false 可关闭)。
  • 到期:文件项可以询问有效期。到期前十五天在铃铛中通知所有者;“已收到”和详情显示剩余天数,“重新索取”会只针对该文件发起新的请求。
错误

This link does not work any more.

它已被移除、已过期、已被使用、所指内容已移到回收站,或者地址在传递过程中被改动:具体是哪一种,链接不会告诉持有者。

This link asks for its password. · That is not the password.

链接页面会先要求输入密码,并在每次请求时发送。

通知

通知相关人员

见动态与通知:每次共享都会调用 onShare,你可以借此发送邮件或应用内通知。