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

Function uploadToCatbox

native.ts:188–213  ·  view source on GitHub ↗
(
    _: IpcMainInvokeEvent,
    fileBuffer: ArrayBuffer,
    filename: string,
    userhash?: string
)

Source from the content-addressed store, hash-verified

186}
187
188export async function uploadToCatbox(
189 _: IpcMainInvokeEvent,
190 fileBuffer: ArrayBuffer,
191 filename: string,
192 userhash?: string
193): Promise<NativeUploadResult> {
194 try {
195 const fields: Record<string, string> = { reqtype: "fileupload" };
196 if (userhash) fields.userhash = userhash;
197 const response = await multipartFetch("https://catbox.moe/user/api.php", fields, "fileToUpload", fileBuffer, filename);
198
199 if (!response.ok) {
200 const errorText = await response.text();
201 return { success: false, error: `Upload failed: ${response.status} ${errorText}` };
202 }
203
204 const text = (await response.text()).trim();
205 if (!text) {
206 return { success: false, error: "No URL returned from upload" };
207 }
208
209 return { success: true, url: text };
210 } catch (e) {
211 return { success: false, error: e instanceof Error ? e.message : "Unknown error" };
212 }
213}
214
215export async function uploadToLitterbox(
216 _: IpcMainInvokeEvent,

Callers

nothing calls this directly

Calls 2

multipartFetchFunction · 0.85
textMethod · 0.80

Tested by

no test coverage detected