Download a SharePoint file by its sharing URL via the Graph `/shares` API.
( contentUrl: string, token: string, )
| 134 | |
| 135 | /** Download a SharePoint file by its sharing URL via the Graph `/shares` API. */ |
| 136 | async 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 |
no test coverage detected
searching dependent graphs…