Fix/ecommerce 502 bug #3

Merged
stringadmin merged 5 commits from fix/ecommerce-502-bug into master 2026-06-02 09:01:38 +00:00
Showing only changes of commit 9504f8ee87 - Show all commits
@@ -9,7 +9,6 @@ import {
type AdVideoUserConfig, type AdVideoUserConfig,
} from "../../api/adVideoPlanClient"; } from "../../api/adVideoPlanClient";
import { aiGenerationClient } from "../../api/aiGenerationClient"; import { aiGenerationClient } from "../../api/aiGenerationClient";
import { uploadAssetWithProgress } from "../../api/uploadWithProgress";
import { waitForTask } from "../../api/taskSubscription"; import { waitForTask } from "../../api/taskSubscription";
import { resolveVideoRequestModel } from "../../utils/resolveVideoModel"; import { resolveVideoRequestModel } from "../../utils/resolveVideoModel";
import type { import type {
@@ -34,12 +33,18 @@ export async function runVideoPlan(
onStepStart("upload"); onStepStart("upload");
const imageUrls: string[] = []; const imageUrls: string[] = [];
for (const dataUrl of imageDataUrls) { const SUPPORTED_IMAGE_TYPES = new Set(["image/jpeg", "image/png", "image/webp", "image/gif"]);
const result = await uploadAssetWithProgress( for (const srcUrl of imageDataUrls) {
{ dataUrl, scope: "ecommerce-product", mimeType: "image/png" }, try {
{ signal }, const resp = await fetch(srcUrl);
); const rawBlob = await resp.blob();
const mimeType = SUPPORTED_IMAGE_TYPES.has(rawBlob.type) ? rawBlob.type : "image/png";
const blob = rawBlob.type === mimeType ? rawBlob : new Blob([rawBlob], { type: mimeType });
const result = await aiGenerationClient.uploadAssetBinary(blob, { mimeType, scope: "ecommerce-product" });
imageUrls.push(result.url); imageUrls.push(result.url);
} catch {
// skip images that fail to upload
}
} }
onStepDone("upload"); onStepDone("upload");