(fileBlob: Blob, filename: string)
| 839 | } |
| 840 | |
| 841 | async function uploadToTempSh(fileBlob: Blob, filename: string): Promise<string> { |
| 842 | if (Native) { |
| 843 | const result = await Native.uploadToTempSh(await fileBlob.arrayBuffer(), filename); |
| 844 | if (!result.success || !result.url) throw new Error(result.error || "No URL returned from upload"); |
| 845 | return result.url; |
| 846 | } |
| 847 | |
| 848 | const formData = new FormData(); |
| 849 | formData.append("file", fileBlob, filename); |
| 850 | |
| 851 | const uploadUrl = "https://temp.sh/upload"; |
| 852 | const response = await uploadRequestWithTimeout(uploadUrl, { |
| 853 | method: "POST", |
| 854 | body: formData |
| 855 | }); |
| 856 | |
| 857 | if (!response.ok) { |
| 858 | throw new Error(`Upload failed: ${response.status} ${await response.text()}`); |
| 859 | } |
| 860 | |
| 861 | const text = (await response.text()).trim(); |
| 862 | if (!text) throw new Error("No URL returned from upload"); |
| 863 | return text; |
| 864 | } |
| 865 | |
| 866 | function makeRandomHex(length = 12): string { |
| 867 | const bytes = new Uint8Array(length); |
no test coverage detected