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

Function uploadToTmpfiles

native.ts:277–304  ·  view source on GitHub ↗
(
    _: IpcMainInvokeEvent,
    fileBuffer: ArrayBuffer,
    filename: string
)

Source from the content-addressed store, hash-verified

275}
276
277export async function uploadToTmpfiles(
278 _: IpcMainInvokeEvent,
279 fileBuffer: ArrayBuffer,
280 filename: string
281): Promise<NativeUploadResult> {
282 try {
283 const response = await multipartFetch("https://tmpfiles.org/api/v1/upload", {}, "file", fileBuffer, filename);
284
285 if (!response.ok) {
286 const errorText = await response.text();
287 return { success: false, error: `Upload failed: ${response.status} ${errorText}` };
288 }
289
290 const data = await response.json() as { status?: string; data?: { url?: string; }; };
291 const rawUrl = data.data?.url || "";
292 if (!rawUrl || data.status !== "success") {
293 return { success: false, error: "No URL returned from upload" };
294 }
295
296 const url = rawUrl.includes("tmpfiles.org/") && !rawUrl.includes("/dl/")
297 ? rawUrl.replace(/tmpfiles\.org\/(\d+)/, "tmpfiles.org/dl/$1")
298 : rawUrl;
299
300 return { success: true, url };
301 } catch (e) {
302 return { success: false, error: e instanceof Error ? e.message : "Unknown error" };
303 }
304}
305
306export async function uploadToBuzzheavier(
307 _: IpcMainInvokeEvent,

Callers

nothing calls this directly

Calls 3

multipartFetchFunction · 0.85
textMethod · 0.80
jsonMethod · 0.80

Tested by

no test coverage detected