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

Function downloadFileContent

apps/sim/connectors/dropbox/dropbox.ts:72–100  ·  view source on GitHub ↗
(accessToken: string, filePath: string)

Source from the content-addressed store, hash-verified

70}
71
72async function downloadFileContent(accessToken: string, filePath: string): Promise<string> {
73 const response = await fetchWithRetry('https://content.dropboxapi.com/2/files/download', {
74 method: 'POST',
75 headers: {
76 Authorization: `Bearer ${accessToken}`,
77 'Dropbox-API-Arg': JSON.stringify({ path: filePath }),
78 },
79 })
80
81 if (!response.ok) {
82 throw new Error(`Failed to download file ${filePath}: ${response.status}`)
83 }
84
85 // Stream with a hard byte cap so a file whose listing metadata under-reported
86 // (or omitted) its size can never be fully buffered into memory. Oversize raises
87 // so getDocument can surface it as a skipped (failed) row rather than dropping it.
88 const buffer = await readBodyWithLimit(response, MAX_FILE_SIZE)
89 if (!buffer) {
90 throw new ConnectorFileTooLargeError(MAX_FILE_SIZE)
91 }
92
93 const text = buffer.toString('utf8')
94
95 if (filePath.endsWith('.html') || filePath.endsWith('.htm')) {
96 return htmlToPlainText(text)
97 }
98
99 return text
100}
101
102function fileToStub(entry: DropboxFileEntry): ExternalDocument {
103 return {

Callers 1

dropbox.tsFile · 0.70

Calls 4

fetchWithRetryFunction · 0.90
readBodyWithLimitFunction · 0.90
htmlToPlainTextFunction · 0.90
toStringMethod · 0.45

Tested by

no test coverage detected