* 保存附件到本地 * @param fileId 文件ID * @param fileName 文件名 * @param base64Content base64编码的文件内容 * @param pageId 页面ID(可选) * @param messageId 消息ID(可选) * @returns 相对路径
(
fileId: string,
fileName: string,
base64Content: string,
pageId?: string,
messageId?: string
)
| 24 | * @returns 相对路径 |
| 25 | */ |
| 26 | async saveAttachment( |
| 27 | fileId: string, |
| 28 | fileName: string, |
| 29 | base64Content: string, |
| 30 | pageId?: string, |
| 31 | messageId?: string |
| 32 | ): Promise<{ success: boolean; localPath?: string; error?: string }> { |
| 33 | try { |
| 34 | const relativePath = await saveAttachmentFile({ |
| 35 | fileId, |
| 36 | fileName, |
| 37 | base64Content, |
| 38 | pageId, |
| 39 | messageId |
| 40 | }) |
| 41 | return { success: true, localPath: relativePath } |
| 42 | } catch (error) { |
| 43 | console.error('保存附件失败:', error) |
| 44 | return { |
| 45 | success: false, |
| 46 | error: error instanceof Error ? error.message : '保存附件失败' |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * 读取附件内容 |
no test coverage detected