(fileBlob: Blob, filename: string)
| 711 | } |
| 712 | |
| 713 | async function uploadToLitterbox(fileBlob: Blob, filename: string): Promise<string> { |
| 714 | const expiry = settings.store.litterboxExpiry || "24h"; |
| 715 | |
| 716 | if (Native) { |
| 717 | const result = await Native.uploadToLitterbox(await fileBlob.arrayBuffer(), filename, expiry); |
| 718 | if (!result.success || !result.url) throw new Error(result.error || "No URL returned from upload"); |
| 719 | return result.url; |
| 720 | } |
| 721 | |
| 722 | const formData = new FormData(); |
| 723 | formData.append("reqtype", "fileupload"); |
| 724 | formData.append("time", expiry); |
| 725 | formData.append("fileToUpload", fileBlob, filename); |
| 726 | |
| 727 | const response = await uploadRequestWithTimeout("https://litterbox.catbox.moe/resources/internals/api.php", { |
| 728 | method: "POST", |
| 729 | body: formData |
| 730 | }); |
| 731 | |
| 732 | if (!response.ok) throw new Error(`Upload failed: ${response.status} ${await response.text()}`); |
| 733 | const text = (await response.text()).trim(); |
| 734 | if (!text) throw new Error("No URL returned from upload"); |
| 735 | return text; |
| 736 | } |
| 737 | |
| 738 | async function uploadToGofile(fileBlob: Blob, filename: string): Promise<string> { |
| 739 | const { gofileToken } = settings.store as { gofileToken?: string; }; |
no test coverage detected