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

Function createWebdavShare

native.ts:486–525  ·  view source on GitHub ↗
(
    _: IpcMainInvokeEvent,
    ocsUrl: string,
    headers: Record<string, string>,
    body: string
)

Source from the content-addressed store, hash-verified

484}
485
486export async function createWebdavShare(
487 _: IpcMainInvokeEvent,
488 ocsUrl: string,
489 headers: Record<string, string>,
490 body: string
491): Promise<NativeUploadResult> {
492 if (!isValidHttpsUrl(ocsUrl)) {
493 return { success: false, error: "Invalid or non-HTTPS share endpoint URL" };
494 }
495
496 try {
497 const response = await fetch(ocsUrl, {
498 method: "POST",
499 headers,
500 body
501 });
502
503 const text = await response.text();
504
505 if (!response.ok) {
506 return { success: false, error: `Share creation failed: ${response.status} ${text.slice(0, 200)}` };
507 }
508
509 let data: { ocs?: { data?: { token?: string; }; }; };
510 try {
511 data = JSON.parse(text);
512 } catch {
513 return { success: false, error: `Invalid share response: ${text.slice(0, 200)}` };
514 }
515
516 const token = data?.ocs?.data?.token;
517 if (!token) {
518 return { success: false, error: "No share token in server response" };
519 }
520
521 return { success: true, url: token };
522 } catch (e) {
523 return { success: false, error: e instanceof Error ? e.message : "Unknown error" };
524 }
525}
526
527export async function fetchFile(
528 _: IpcMainInvokeEvent,

Callers

nothing calls this directly

Calls 2

isValidHttpsUrlFunction · 0.85
textMethod · 0.80

Tested by

no test coverage detected