( image: AIImage, httpClient: HttpClient, token?: AbortToken, )
| 873 | }; |
| 874 | |
| 875 | const resolveAIImageData = async ( |
| 876 | image: AIImage, |
| 877 | httpClient: HttpClient, |
| 878 | token?: AbortToken, |
| 879 | ): Promise<AIImage | null> => { |
| 880 | if (image.data) return image; |
| 881 | if (!image.url) return null; |
| 882 | const response = await httpClient.request( |
| 883 | { |
| 884 | url: image.url, |
| 885 | method: "GET", |
| 886 | responseType: "arraybuffer", |
| 887 | }, |
| 888 | token, |
| 889 | ); |
| 890 | const contentType = |
| 891 | getHeaderContentType(response.headers) || |
| 892 | image.mimeType || |
| 893 | "image/jpeg"; |
| 894 | return { data: Buffer.from(response.data), mimeType: contentType }; |
| 895 | }; |
| 896 | |
| 897 | const getVideoExtensionForMime = (mimeType: string): string => { |
| 898 | if (mimeType === "video/webm") return ".webm"; |
no test coverage detected