UNPKG

article-writer-cn

Version:

AI 驱动的智能写作系统 - 专注公众号/自媒体文章创作

39 lines 1.13 kB
/** * Cloudflare R2 图床提供者 * 使用 S3 兼容 API 上传图片到 Cloudflare R2 * * 参考文档: https://developers.cloudflare.com/r2/api/s3/api/ */ import type { ImageBedProvider, ImageBedType, UploadResult, CloudflareR2Config } from '../types.js'; export declare class CloudflareR2Provider implements ImageBedProvider { readonly type: ImageBedType; private config; private s3Client; constructor(config: CloudflareR2Config); /** * 上传单张图片到 R2 */ upload(imagePath: string, remotePath?: string): Promise<UploadResult>; /** * 批量上传图片 */ uploadBatch(imagePaths: string[]): Promise<UploadResult[]>; /** * 验证配置是否有效 */ validateConfig(): Promise<boolean>; /** * 生成远程文件路径 * 格式: images/{year}/{month}/{hash}-{filename} */ private generateRemotePath; /** * 根据文件扩展名确定 Content-Type */ private getContentType; /** * 构建公开访问 URL */ private buildPublicUrl; } //# sourceMappingURL=cloudflare-r2-provider.d.ts.map