MCPcopy Create free account
hub / github.com/experdot/pointer / saveAttachmentFile

Function saveAttachmentFile

src/main/attachmentStorage.ts:83–102  ·  view source on GitHub ↗
(options: {
  fileId: string
  fileName: string
  base64Content: string
  pageId?: string
  messageId?: string
})

Source from the content-addressed store, hash-verified

81}
82
83export async function saveAttachmentFile(options: {
84 fileId: string
85 fileName: string
86 base64Content: string
87 pageId?: string
88 messageId?: string
89}): Promise<string> {
90 const relativePath = buildStoredRelativePath(
91 options.fileId,
92 options.fileName,
93 options.pageId,
94 options.messageId
95 )
96 const targetPath = await resolveAttachmentPath(relativePath)
97
98 await mkdir(path.dirname(targetPath), { recursive: true })
99 await writeFile(targetPath, Buffer.from(options.base64Content, 'base64'))
100
101 return relativePath
102}
103
104export async function readAttachmentFile(localPath: string): Promise<string> {
105 const targetPath = await resolveAttachmentPath(localPath)

Callers 1

saveAttachmentMethod · 0.90

Calls 2

buildStoredRelativePathFunction · 0.85
resolveAttachmentPathFunction · 0.85

Tested by

no test coverage detected