MCPcopy Create free account
hub / github.com/ScattrdBlade/bigFileUpload / uploadToWebdav

Function uploadToWebdav

native.ts:462–484  ·  view source on GitHub ↗
(
    _: IpcMainInvokeEvent,
    fileBuffer: ArrayBuffer,
    uploadUrl: string,
    headers: Record<string, string>
)

Source from the content-addressed store, hash-verified

460}
461
462export async function uploadToWebdav(
463 _: IpcMainInvokeEvent,
464 fileBuffer: ArrayBuffer,
465 uploadUrl: string,
466 headers: Record<string, string>
467): Promise<NativeUploadResult> {
468 if (!isValidHttpsUrl(uploadUrl)) {
469 return { success: false, error: "Invalid or non-HTTPS upload URL" };
470 }
471
472 try {
473 const response = await rawFetch(uploadUrl, "PUT", fileBuffer, headers);
474
475 if (!response.ok) {
476 const errorText = await response.text();
477 return { success: false, error: `Upload failed: ${response.status} ${errorText}` };
478 }
479
480 return { success: true, url: uploadUrl };
481 } catch (e) {
482 return { success: false, error: e instanceof Error ? e.message : "Unknown error" };
483 }
484}
485
486export async function createWebdavShare(
487 _: IpcMainInvokeEvent,

Callers

nothing calls this directly

Calls 3

isValidHttpsUrlFunction · 0.85
rawFetchFunction · 0.85
textMethod · 0.80

Tested by

no test coverage detected