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

Function uploadToLitterbox

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

Source from the content-addressed store, hash-verified

711}
712
713async function uploadToLitterbox(fileBlob: Blob, filename: string): Promise<string> {
714 const expiry = settings.store.litterboxExpiry || "24h";
715
716 if (Native) {
717 const result = await Native.uploadToLitterbox(await fileBlob.arrayBuffer(), filename, expiry);
718 if (!result.success || !result.url) throw new Error(result.error || "No URL returned from upload");
719 return result.url;
720 }
721
722 const formData = new FormData();
723 formData.append("reqtype", "fileupload");
724 formData.append("time", expiry);
725 formData.append("fileToUpload", fileBlob, filename);
726
727 const response = await uploadRequestWithTimeout("https://litterbox.catbox.moe/resources/internals/api.php", {
728 method: "POST",
729 body: formData
730 });
731
732 if (!response.ok) throw new Error(`Upload failed: ${response.status} ${await response.text()}`);
733 const text = (await response.text()).trim();
734 if (!text) throw new Error("No URL returned from upload");
735 return text;
736}
737
738async function uploadToGofile(fileBlob: Blob, filename: string): Promise<string> {
739 const { gofileToken } = settings.store as { gofileToken?: string; };

Callers 1

uploadToServiceFunction · 0.70

Calls 2

uploadRequestWithTimeoutFunction · 0.85
textMethod · 0.80

Tested by

no test coverage detected