using WebDrop.FileProtocol; namespace WebDrop.Core; /// 给客户端的文件服务入口:地址 + 一张短期票据 public sealed record FileGrant(string Url, string Ticket, long ExpiresAt); /// /// 主后端和文件服务之间的接口。关闭时(默认)所有帧仍然存在主后端自己的存储里,行为和以前完全一样; /// 打开后,文件的内容(文件域的对象,不分大小)由客户端直接传给文件服务,主后端只登记元数据和摘要;聊天、头像、目录仍在主后端。 /// public interface IFileGateway { bool Enabled { get; } /// 客户端拿到的文件服务根地址(经反向隧道对外的那个) string PublicUrl { get; } FileGrant Issue(FileOp op, Id16 channel, Id16 item, uint from, long nowMs); bool TryVerifyReceipt(string? token, long nowMs, out FileReceipt receipt); } public sealed class NoFileGateway : IFileGateway { public static readonly NoFileGateway Instance = new(); public bool Enabled => false; public string PublicUrl => ""; public FileGrant Issue(FileOp op, Id16 channel, Id16 item, uint from, long nowMs) => throw new WebDropException(ErrorCode.NotFound); public bool TryVerifyReceipt(string? token, long nowMs, out FileReceipt receipt) { receipt = null!; return false; } }