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

Function uploadToEzHost

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

Source from the content-addressed store, hash-verified

112}
113
114export async function uploadToEzHost(
115 _: IpcMainInvokeEvent,
116 fileBuffer: ArrayBuffer,
117 filename: string,
118 key: string
119): Promise<NativeUploadResult> {
120 try {
121 const response = await multipartFetch("https://api.e-z.host/files", {}, "file", fileBuffer, filename, { key });
122
123 if (!response.ok) {
124 const errorText = await response.text();
125 return { success: false, error: `Upload failed: ${response.status} ${errorText}` };
126 }
127
128 const data = await response.json() as { success: boolean; error?: string; imageUrl?: string; rawUrl?: string; };
129
130 if (!data || !data.success) {
131 return { success: false, error: data?.error || "Upload failed" };
132 }
133
134 if (data.imageUrl || data.rawUrl) {
135 return { success: true, url: data.imageUrl || data.rawUrl };
136 }
137
138 return { success: false, error: "No URL returned from upload" };
139 } catch (e) {
140 return { success: false, error: e instanceof Error ? e.message : "Unknown error" };
141 }
142}
143
144export async function uploadTo0x0(
145 _: IpcMainInvokeEvent,

Callers

nothing calls this directly

Calls 3

multipartFetchFunction · 0.85
textMethod · 0.80
jsonMethod · 0.80

Tested by

no test coverage detected