(
_: IpcMainInvokeEvent,
fileBuffer: ArrayBuffer,
filename: string,
expiry: string
)
| 213 | } |
| 214 | |
| 215 | export async function uploadToLitterbox( |
| 216 | _: IpcMainInvokeEvent, |
| 217 | fileBuffer: ArrayBuffer, |
| 218 | filename: string, |
| 219 | expiry: string |
| 220 | ): Promise<NativeUploadResult> { |
| 221 | try { |
| 222 | const response = await multipartFetch("https://litterbox.catbox.moe/resources/internals/api.php", { reqtype: "fileupload", time: expiry }, "fileToUpload", fileBuffer, filename); |
| 223 | |
| 224 | if (!response.ok) { |
| 225 | const errorText = await response.text(); |
| 226 | return { success: false, error: `Upload failed: ${response.status} ${errorText}` }; |
| 227 | } |
| 228 | |
| 229 | const text = (await response.text()).trim(); |
| 230 | if (!text) { |
| 231 | return { success: false, error: "No URL returned from upload" }; |
| 232 | } |
| 233 | |
| 234 | return { success: true, url: text }; |
| 235 | } catch (e) { |
| 236 | return { success: false, error: e instanceof Error ? e.message : "Unknown error" }; |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | export async function uploadToGofile( |
| 241 | _: IpcMainInvokeEvent, |
nothing calls this directly
no test coverage detected