(
_: IpcMainInvokeEvent,
fileBuffer: ArrayBuffer,
filename: string,
uploadKey: string
)
| 382 | } |
| 383 | |
| 384 | export async function uploadToPixelVault( |
| 385 | _: IpcMainInvokeEvent, |
| 386 | fileBuffer: ArrayBuffer, |
| 387 | filename: string, |
| 388 | uploadKey: string |
| 389 | ): Promise<NativeUploadResult> { |
| 390 | try { |
| 391 | const response = await multipartFetch("https://pixelvault.co/", {}, "file", fileBuffer, filename, { Authorization: uploadKey }); |
| 392 | |
| 393 | const text = await response.text(); |
| 394 | let data: { resource?: string; url?: string; } | null = null; |
| 395 | |
| 396 | try { |
| 397 | data = text ? JSON.parse(text) : null; |
| 398 | } catch { |
| 399 | data = null; |
| 400 | } |
| 401 | |
| 402 | if (!response.ok) { |
| 403 | return { success: false, error: `Upload failed: ${response.status} ${text}` }; |
| 404 | } |
| 405 | |
| 406 | const url = data?.resource || data?.url || text.trim(); |
| 407 | if (!url) { |
| 408 | return { success: false, error: "No URL returned from upload" }; |
| 409 | } |
| 410 | |
| 411 | return { success: true, url }; |
| 412 | } catch (e) { |
| 413 | return { success: false, error: e instanceof Error ? e.message : "Unknown error" }; |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | export async function uploadToPixelDrain( |
| 418 | _: IpcMainInvokeEvent, |
nothing calls this directly
no test coverage detected