* 读取附件内容 * @param localPath 相对路径 * @returns base64编码的内容
(
localPath: string
)
| 68 | * @returns base64编码的内容 |
| 69 | */ |
| 70 | async readAttachment( |
| 71 | localPath: string |
| 72 | ): Promise<{ success: boolean; content?: string; error?: string }> { |
| 73 | try { |
| 74 | const fullPath = path.join(this.attachmentsDir, localPath) |
| 75 | const buffer = await readFile(fullPath) |
| 76 | const base64 = buffer.toString('base64') |
| 77 | return { success: true, content: base64 } |
| 78 | } catch (error) { |
| 79 | console.error('读取附件失败:', error) |
| 80 | return { |
| 81 | success: false, |
| 82 | error: error instanceof Error ? error.message : '读取附件失败' |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * 删除附件 |
no outgoing calls
no test coverage detected