MCPcopy Index your code
hub / github.com/deepnote/deepnote / uploadFile

Function uploadFile

packages/cli/src/utils/import-client.ts:72–91  ·  view source on GitHub ↗
(uploadUrl: string, fileBuffer: Buffer)

Source from the content-addressed store, hash-verified

70 * @throws Error if the upload fails
71 */
72export async function uploadFile(uploadUrl: string, fileBuffer: Buffer): Promise<void> {
73 debug(`Uploading file (${fileBuffer.length} bytes)`)
74
75 const response = await fetch(uploadUrl, {
76 method: 'PUT',
77 headers: {
78 'Content-Type': 'application/octet-stream',
79 'Content-Length': fileBuffer.length.toString(),
80 },
81 body: fileBuffer,
82 })
83
84 if (!response.ok) {
85 const responseText = await response.text()
86 debug(`Upload failed - Status: ${response.status}, Response: ${responseText}`)
87 throw new ImportError(responseText || 'Upload failed', response.status)
88 }
89
90 debug('File uploaded successfully')
91}
92
93/**
94 * Builds the launch URL for opening in Deepnote.

Callers 2

openDeepnoteFileInCloudFunction · 0.90

Calls 1

debugFunction · 0.90

Tested by

no test coverage detected