3D 产物的 content type 与落库值同源
- server-rs/crates/api-server/src/tripo3d/storage.rs:返回给调用方的 content_type 改为优先取 HEAD 复核回来的值(取不到才回落到本地解析值),与 asset_object.content_type 用同一份取值。此前接口返回的是本地解析值、落库的是 OSS 回显值,OSS 一旦归一化或回显空值,两个来源就会给出互相矛盾的元数据
This commit is contained in:
@@ -156,6 +156,12 @@ pub(crate) async fn store_model3d_artifact(
|
||||
)
|
||||
.await
|
||||
.map_err(|error| map_oss_error(error, "aliyun-oss"))?;
|
||||
// HEAD 复核回来的 Content-Type 才是落库与对外共用的那份:只把本地解析值给调用方,
|
||||
// 会出现「接口返回的 content type」与「asset_object.content_type」不一致。
|
||||
let effective_content_type = head
|
||||
.content_type
|
||||
.clone()
|
||||
.unwrap_or_else(|| content_type.clone());
|
||||
let now_micros = current_utc_micros();
|
||||
// asset_object 的 ID 必须是 (owner, operation_kind, operation_id, slot) 的稳定派生值,
|
||||
// 否则 SpacetimeDB 侧会以“生成结果 asset object ID 不是 operation 稳定 ID”拒绝整笔提交。
|
||||
@@ -169,7 +175,7 @@ pub(crate) async fn store_model3d_artifact(
|
||||
head.bucket,
|
||||
head.object_key.clone(),
|
||||
AssetObjectAccessPolicy::Private,
|
||||
head.content_type.or(Some(content_type.clone())),
|
||||
Some(effective_content_type.clone()),
|
||||
head.content_length,
|
||||
Some(sha256.clone()),
|
||||
MODEL3D_ASSET_KIND.to_string(),
|
||||
@@ -182,7 +188,7 @@ pub(crate) async fn store_model3d_artifact(
|
||||
.map_err(map_editor_asset_field_error)?;
|
||||
Ok(StoredModel3dArtifact {
|
||||
object_key: head.object_key,
|
||||
content_type,
|
||||
content_type: effective_content_type,
|
||||
content_length: head.content_length,
|
||||
sha256,
|
||||
asset_object,
|
||||
|
||||
Reference in New Issue
Block a user