(
_: IpcMainInvokeEvent,
fileBuffer: ArrayBuffer,
uploadUrl: string,
headers: Record<string, string>
)
| 460 | } |
| 461 | |
| 462 | export async function uploadToWebdav( |
| 463 | _: IpcMainInvokeEvent, |
| 464 | fileBuffer: ArrayBuffer, |
| 465 | uploadUrl: string, |
| 466 | headers: Record<string, string> |
| 467 | ): Promise<NativeUploadResult> { |
| 468 | if (!isValidHttpsUrl(uploadUrl)) { |
| 469 | return { success: false, error: "Invalid or non-HTTPS upload URL" }; |
| 470 | } |
| 471 | |
| 472 | try { |
| 473 | const response = await rawFetch(uploadUrl, "PUT", fileBuffer, headers); |
| 474 | |
| 475 | if (!response.ok) { |
| 476 | const errorText = await response.text(); |
| 477 | return { success: false, error: `Upload failed: ${response.status} ${errorText}` }; |
| 478 | } |
| 479 | |
| 480 | return { success: true, url: uploadUrl }; |
| 481 | } catch (e) { |
| 482 | return { success: false, error: e instanceof Error ? e.message : "Unknown error" }; |
| 483 | } |
| 484 | } |
| 485 | |
| 486 | export async function createWebdavShare( |
| 487 | _: IpcMainInvokeEvent, |
nothing calls this directly
no test coverage detected