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

Function uploadToCatbox

utils/upload.ts:669–692  ·  view source on GitHub ↗
(fileBlob: Blob, filename: string)

Source from the content-addressed store, hash-verified

667}
668
669async function uploadToCatbox(fileBlob: Blob, filename: string): Promise<string> {
670 const { catboxUserhash } = settings.store;
671
672 if (Native) {
673 const result = await Native.uploadToCatbox(await fileBlob.arrayBuffer(), filename, catboxUserhash || undefined);
674 if (!result.success || !result.url) throw new Error(result.error || "No URL returned from upload");
675 return result.url;
676 }
677
678 const formData = new FormData();
679 formData.append("reqtype", "fileupload");
680 if (catboxUserhash) formData.append("userhash", catboxUserhash);
681 formData.append("fileToUpload", fileBlob, filename);
682
683 const response = await uploadRequestWithTimeout("https://catbox.moe/user/api.php", {
684 method: "POST",
685 body: formData
686 });
687
688 if (!response.ok) throw new Error(`Upload failed: ${response.status} ${await response.text()}`);
689 const text = (await response.text()).trim();
690 if (!text) throw new Error("No URL returned from upload");
691 return text;
692}
693
694async function uploadTo0x0(fileBlob: Blob, filename: string): Promise<string> {
695 if (!Native) {

Callers 1

uploadToServiceFunction · 0.70

Calls 2

uploadRequestWithTimeoutFunction · 0.85
textMethod · 0.80

Tested by

no test coverage detected