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

Function uploadToGofile

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

Source from the content-addressed store, hash-verified

736}
737
738async function uploadToGofile(fileBlob: Blob, filename: string): Promise<string> {
739 const { gofileToken } = settings.store as { gofileToken?: string; };
740
741 if (Native) {
742 const result = await Native.uploadToGofile(await fileBlob.arrayBuffer(), filename, gofileToken || undefined);
743 if (!result.success || !result.url) throw new Error(result.error || "No URL returned from upload");
744 return result.url;
745 }
746
747 const formData = new FormData();
748 if (gofileToken?.trim()) {
749 formData.append("token", gofileToken.trim());
750 }
751 formData.append("file", fileBlob, filename);
752
753 const uploadUrl = "https://upload.gofile.io/uploadfile";
754 const response = await uploadRequestWithTimeout(uploadUrl, {
755 method: "POST",
756 body: formData
757 });
758
759 if (!response.ok) {
760 throw new Error(`Upload failed: ${response.status} ${await response.text()}`);
761 }
762
763 const data = await response.json() as {
764 status?: string;
765 error?: string;
766 data?: { downloadPage?: string; code?: string; };
767 };
768
769 if (data.status !== "ok") {
770 throw new Error(data.error || "Upload failed");
771 }
772
773 const url = data.data?.downloadPage || (data.data?.code ? `https://gofile.io/d/${data.data.code}` : "");
774 if (!url) throw new Error("No URL returned from upload");
775 return url;
776}
777
778async function uploadToTmpfiles(fileBlob: Blob, filename: string): Promise<string> {
779 if (Native) {

Callers 1

uploadToServiceFunction · 0.70

Calls 3

uploadRequestWithTimeoutFunction · 0.85
textMethod · 0.80
jsonMethod · 0.80

Tested by

no test coverage detected