(fileUrl: string)
| 706 | } |
| 707 | |
| 708 | async function checkFileUrl(fileUrl: string) { |
| 709 | if (isBASE64Data(fileUrl)) return; |
| 710 | const response = await fetch(fileUrl, { method: "HEAD" }); |
| 711 | if (response.status >= 400) throw new Error(`File ${fileUrl} is not valid: [${response.status}] ${response.statusText}`); |
| 712 | const contentLength = response.headers.get("content-length"); |
| 713 | if (contentLength) { |
| 714 | const fileSize = parseInt(contentLength, 10); |
| 715 | if (fileSize > FILE_MAX_SIZE) throw new Error(`File ${fileUrl} exceeds size limit`); |
| 716 | } |
| 717 | } |
| 718 | |
| 719 | async function uploadFile(fileUrl: string, refreshToken: string, isVideoImage = false) { |
| 720 | await checkFileUrl(fileUrl); |
no test coverage detected