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,
} from "../../api/adVideoPlanClient";
import { aiGenerationClient } from "../../api/aiGenerationClient";
import { uploadAssetWithProgress } from "../../api/uploadWithProgress";
import { waitForTask } from "../../api/taskSubscription";
import { resolveVideoRequestModel } from "../../utils/resolveVideoModel";
import type {
@@ -34,12 +33,18 @@ export async function runVideoPlan(
onStepStart("upload");
const imageUrls: string[] = [];
for (const dataUrl of imageDataUrls) {
const result = await uploadAssetWithProgress(
{ dataUrl, scope: "ecommerce-product", mimeType: "image/png" },
{ signal },
);
const SUPPORTED_IMAGE_TYPES = new Set(["image/jpeg", "image/png", "image/webp", "image/gif"]);
for (const srcUrl of imageDataUrls) {
try {
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);
} catch {
// skip images that fail to upload
}
}
onStepDone("upload");