Files
server/dist/services/CloudflareShareService.d.ts
wdvipa 450367dea2 111
2026-02-09 16:34:01 +08:00

81 lines
1.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Cloudflare文件分享服务
* 用于生成临时文件分享链接有效期10分钟
*/
export declare class CloudflareShareService {
private logger;
private activeShares;
private cleanupInterval;
constructor();
/**
* 为文件创建临时分享链接
* @param filePath 文件路径
* @param filename 文件名
* @param durationMinutes 有效期分钟默认10分钟
* @returns 分享链接信息
*/
createShareLink(filePath: string, filename: string, durationMinutes?: number): Promise<ShareResult>;
/**
* 停止分享会话
*/
stopShare(sessionId: string): Promise<boolean>;
/**
* 获取活动分享会话列表
*/
getActiveShares(): ShareInfo[];
/**
* 清理过期的分享会话
*/
private cleanupExpiredShares;
/**
* 查找cloudflared可执行文件
*/
private findCloudflared;
/**
* 查找可用端口
*/
private findAvailablePort;
/**
* 创建文件服务器
*/
private createFileServer;
/**
* 启动cloudflared隧道
*/
private startCloudflaredTunnel;
/**
* 从cloudflared输出中提取隧道URL
*/
private extractTunnelUrl;
/**
* 生成会话ID
*/
private generateSessionId;
/**
* 格式化文件大小
*/
private formatFileSize;
/**
* 销毁服务
*/
destroy(): void;
}
interface ShareResult {
success: boolean;
sessionId?: string;
shareUrl?: string;
filename?: string;
expiresAt?: string;
durationMinutes?: number;
error?: string;
}
interface ShareInfo {
sessionId: string;
filename: string;
shareUrl: string;
createdAt: string;
expiresAt: string;
isExpired: boolean;
}
export default CloudflareShareService;
//# sourceMappingURL=CloudflareShareService.d.ts.map