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

Function uploadToGofile

native.ts:240–275  ·  view source on GitHub ↗
(
    _: IpcMainInvokeEvent,
    fileBuffer: ArrayBuffer,
    filename: string,
    token?: string
)

Source from the content-addressed store, hash-verified

238}
239
240export async function uploadToGofile(
241 _: IpcMainInvokeEvent,
242 fileBuffer: ArrayBuffer,
243 filename: string,
244 token?: string
245): Promise<NativeUploadResult> {
246 try {
247 const fields: Record<string, string> = {};
248 if (token?.trim()) fields.token = token.trim();
249 const response = await multipartFetch("https://upload.gofile.io/uploadfile", fields, "file", fileBuffer, filename);
250
251 if (!response.ok) {
252 const errorText = await response.text();
253 return { success: false, error: `Upload failed: ${response.status} ${errorText}` };
254 }
255
256 const data = await response.json() as {
257 status?: string;
258 error?: string;
259 data?: { downloadPage?: string; code?: string; };
260 };
261
262 if (data.status !== "ok") {
263 return { success: false, error: data.error || "Upload failed" };
264 }
265
266 const url = data.data?.downloadPage || (data.data?.code ? `https://gofile.io/d/${data.data.code}` : "");
267 if (!url) {
268 return { success: false, error: "No URL returned from upload" };
269 }
270
271 return { success: true, url };
272 } catch (e) {
273 return { success: false, error: e instanceof Error ? e.message : "Unknown error" };
274 }
275}
276
277export async function uploadToTmpfiles(
278 _: IpcMainInvokeEvent,

Callers

nothing calls this directly

Calls 3

multipartFetchFunction · 0.85
textMethod · 0.80
jsonMethod · 0.80

Tested by

no test coverage detected