MCPcopy Index your code
hub / github.com/simstudioai/sim / downloadFileContent

Function downloadFileContent

apps/sim/connectors/onedrive/onedrive.ts:72–90  ·  view source on GitHub ↗

* Downloads the raw content of a OneDrive file.

(accessToken: string, fileId: string)

Source from the content-addressed store, hash-verified

70 * Downloads the raw content of a OneDrive file.
71 */
72async function downloadFileContent(accessToken: string, fileId: string): Promise<string> {
73 const url = `${GRAPH_BASE_URL}/me/drive/items/${fileId}/content`
74
75 const response = await fetchWithRetry(url, {
76 method: 'GET',
77 headers: { Authorization: `Bearer ${accessToken}` },
78 redirect: 'follow',
79 })
80
81 if (!response.ok) {
82 throw new Error(`Failed to download file ${fileId}: ${response.status}`)
83 }
84
85 const buffer = await readBodyWithLimit(response, MAX_FILE_SIZE)
86 if (!buffer) {
87 throw new ConnectorFileTooLargeError(MAX_FILE_SIZE)
88 }
89 return buffer.toString('utf8')
90}
91
92/**
93 * Fetches file content, converting HTML to plain text when applicable.

Callers 1

fetchFileContentFunction · 0.70

Calls 3

fetchWithRetryFunction · 0.90
readBodyWithLimitFunction · 0.90
toStringMethod · 0.45

Tested by

no test coverage detected