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

Function streamFetch

native.ts:52–69  ·  view source on GitHub ↗
(url: string, method: string, headers: Record<string, string>, parts: Uint8Array[], contentType?: string)

Source from the content-addressed store, hash-verified

50}
51
52function streamFetch(url: string, method: string, headers: Record<string, string>, parts: Uint8Array[], contentType?: string): Promise<Response> {
53 const total = parts.reduce((sum, part) => sum + part.length, 0);
54 const finalHeaders: Record<string, string> = { ...headers, "Content-Length": String(total) };
55 if (contentType) finalHeaders["Content-Type"] = contentType;
56
57 const controller = new AbortController();
58 activeUploadController = controller;
59
60 return fetch(url, {
61 method,
62 headers: finalHeaders,
63 body: progressStream(parts),
64 duplex: "half",
65 signal: controller.signal
66 } as RequestInit & { duplex: "half"; }).finally(() => {
67 if (activeUploadController === controller) activeUploadController = null;
68 });
69}
70
71function multipartFetch(url: string, fields: Record<string, string>, fileFieldName: string, fileBuffer: ArrayBuffer, filename: string, headers: Record<string, string> = {}): Promise<Response> {
72 const boundary = `----BigFileUpload${Date.now().toString(16)}${Math.random().toString(16).slice(2)}`;

Callers 2

multipartFetchFunction · 0.85
rawFetchFunction · 0.85

Calls 1

progressStreamFunction · 0.85

Tested by

no test coverage detected