MCPcopy Create free account
hub / github.com/scriptscat/scriptcat / getAttachment

Method getAttachment

src/app/repo/agent_chat.ts:119–135  ·  view source on GitHub ↗
(id: string)

Source from the content-addressed store, hash-verified

117
118 // 读取附件数据为 Blob(先查 workspace 新路径,fallback 旧路径)
119 async getAttachment(id: string): Promise<Blob | null> {
120 // 新路径: agents/workspace/uploads/{id}
121 try {
122 const workspace = await getWorkspaceRoot();
123 const dir = await getDirectory(workspace, "uploads");
124 return await (await dir.getFileHandle(id)).getFile();
125 } catch {
126 // 新路径不存在,尝试旧路径
127 }
128 // 旧路径回退: agents/conversations/attachments/{id}
129 try {
130 const dir = await this.getChildDir(ATTACHMENTS_DIR);
131 return await (await dir.getFileHandle(id)).getFile();
132 } catch {
133 return null;
134 }
135 }
136
137 // 删除单个附件(同时清理新旧路径)
138 async deleteAttachment(id: string): Promise<void> {

Callers 7

AttachmentImageFunction · 0.80
AttachmentFileFunction · 0.80
AttachmentAudioFunction · 0.80
handleOPFSApiMethod · 0.80
callLLMMethod · 0.80
agent_chat.test.tsFile · 0.80

Calls 3

getWorkspaceRootFunction · 0.90
getDirectoryFunction · 0.90
getChildDirMethod · 0.80

Tested by

no test coverage detected