产物扩展名兜底认下 image/jpg

- server-rs/crates/platform-tripo/src/common/types.rs:fallback_artifact_extension 补上 image/jpg 分支,非标准写法但确有 provider 这么回,预览图不再落到默认 .glb 后缀
- server-rs/crates/platform-tripo/src/common/types.rs:补用例覆盖 png / jpg / webp 与读不出形态时的 glb 兜底
This commit is contained in:
2026-09-24 18:00:21 +08:00
parent 0c716d7d9c
commit 925be4573d
@@ -293,6 +293,10 @@ fn fallback_artifact_extension(content_type: Option<&str>) -> &'static str {
"png"
} else if content_type.starts_with("image/jpeg") {
"jpg"
} else if content_type.starts_with("image/jpg") {
// `image/jpg` 不是标准写法,但确有 provider 这么回;落到默认 `.glb` 会让一张
// 预览图带上模型后缀,这里按声明值给回 jpg。
"jpg"
} else if content_type.starts_with("image/webp") {
"webp"
} else {
@@ -341,6 +345,27 @@ mod tests {
assert!(!stem.contains('.'), "`..` 必须被中性化:{stem}");
}
#[test]
fn fallback_extension_follows_the_declared_image_content_type() {
assert_eq!(
artifact_filename("preview", Some("image/png"), &artifact_url("/artifact")),
"preview.png"
);
assert_eq!(
artifact_filename("preview", Some("image/jpg"), &artifact_url("/artifact")),
"preview.jpg"
);
assert_eq!(
artifact_filename("preview", Some("image/webp"), &artifact_url("/artifact")),
"preview.webp"
);
// 读不出形态时仍按模型产物兜底。
assert_eq!(
artifact_filename("model", None, &artifact_url("/artifact")),
"model.glb"
);
}
#[test]
fn blank_stem_falls_back_to_a_fixed_name() {
assert_eq!(