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