MCPcopy Index your code
hub / github.com/CopilotKit/CopilotKit / downloadSharedFile

Function downloadSharedFile

packages/bot-teams/src/graph-files.ts:136–148  ·  view source on GitHub ↗

Download a SharePoint file by its sharing URL via the Graph `/shares` API.

(
  contentUrl: string,
  token: string,
)

Source from the content-addressed store, hash-verified

134
135/** Download a SharePoint file by its sharing URL via the Graph `/shares` API. */
136async function downloadSharedFile(
137 contentUrl: string,
138 token: string,
139): Promise<Buffer> {
140 const res = await fetch(
141 `${GRAPH}/shares/${shareIdFor(contentUrl)}/driveItem/content`,
142 { headers: { Authorization: `Bearer ${token}` }, redirect: "follow" },
143 );
144 if (!res.ok) {
145 throw new Error(`download failed (HTTP ${res.status})`);
146 }
147 return Buffer.from(await res.arrayBuffer());
148}
149
150/**
151 * Resolve a channel message's uploaded files into AG-UI content parts via

Callers 1

Calls 3

fetchFunction · 0.85
arrayBufferMethod · 0.80
shareIdForFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…