fix(ecommerce): 502 bug - vision model upgrade + MIME normalization + fallback
- Upgrade VISION_MODEL to qwen3.7-plus (latest, confirmed working with image_url) - Add VISION_FALLBACK_MODEL = qwen-vl-plus for retry on "image format" errors - Normalize upload MIME types: unsupported formats (HEIC/AVIF) fall back to image/png to prevent server saving as .bin which DashScope can't read - Server-side: add image/avif, image/heic, image/heif to MIME_EXTENSIONS Root cause: DashScope returned "image format is illegal" when uploaded images had unrecognized MIME types → saved as .bin → DashScope couldn't decode. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1321,18 +1321,20 @@ function ProductClonePage(_props: ProductClonePageProps = {}) {
|
||||
});
|
||||
|
||||
const uploadProductImages = async (): Promise<string[]> => {
|
||||
const SUPPORTED_IMAGE_TYPES = new Set(["image/jpeg", "image/png", "image/webp", "image/gif"]);
|
||||
const urls: string[] = [];
|
||||
for (const item of productImages) {
|
||||
try {
|
||||
const resp = await fetch(item.src);
|
||||
const blob = await resp.blob();
|
||||
const mimeType = SUPPORTED_IMAGE_TYPES.has(blob.type) ? blob.type : "image/png";
|
||||
const dataUrl = await new Promise<string>((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => resolve(String(reader.result));
|
||||
reader.onerror = () => reject(reader.error);
|
||||
reader.readAsDataURL(blob);
|
||||
});
|
||||
const { url } = await aiGenerationClient.uploadAsset({ dataUrl, name: item.name, mimeType: blob.type });
|
||||
const { url } = await aiGenerationClient.uploadAsset({ dataUrl, name: item.name, mimeType });
|
||||
urls.push(url);
|
||||
} catch {
|
||||
// skip images that fail to upload
|
||||
|
||||
Reference in New Issue
Block a user