fix(upload): support mov assets and large web uploads
Deploy / Build Production Runtime Images (push) Successful in 8m51s
Deploy / Deploy Production (push) Successful in 56s
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been cancelled
Deploy / Deploy Staging (push) Has been cancelled

This commit is contained in:
Xiaoxia AI
2026-06-23 11:44:10 +08:00
parent 9743123abc
commit 2cccc1b1d1
5 changed files with 34 additions and 4 deletions
@@ -0,0 +1,7 @@
def infer_mime_type_from_storage_key(storage_key: str) -> str:
lower_filename = storage_key.rsplit("/", 1)[-1].lower()
if lower_filename.endswith(".mov"):
return "video/quicktime"
if lower_filename.endswith((".mp4", ".m4v", ".avi", ".mkv", ".webm")):
return "video/mp4"
return "image/jpeg"
+3 -4
View File
@@ -8,6 +8,7 @@ from packages.adapters.sqlalchemy_impl import (
SQLAlchemyIngestJobRepository,
)
from packages.domain import Asset, IngestJobStatus
from worker_app.core.asset_types import infer_mime_type_from_storage_key
@celery_app.task(name="worker.ingest_asset")
@@ -37,7 +38,8 @@ def ingest_asset(job_id: str) -> dict:
job_repo.update(job)
# Mock metadata extraction (in real implementation: use ffprobe, Pillow, etc.)
mime_type = "video/mp4" if job.storage_key.endswith(".mp4") else "image/jpeg"
filename = job.storage_key.split("/")[-1]
mime_type = infer_mime_type_from_storage_key(job.storage_key)
metadata = {
"duration": 10.5,
"width": 1920,
@@ -45,9 +47,6 @@ def ingest_asset(job_id: str) -> dict:
"size_bytes": 1024000,
}
# Extract filename from storage_key
filename = job.storage_key.split("/")[-1]
# Create Asset
asset = Asset.create(
workspace_id=job.workspace_id,
+3
View File
@@ -16,6 +16,9 @@ server {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
proxy_request_buffering off;
}
location / {
+2
View File
@@ -70,6 +70,8 @@ def test_production_nginx_static_upstream_requires_web_recreate():
assert "proxy_pass http://xiaoxia-api-production:8000/api/;" in config
assert "client_max_body_size 100m;" in config
assert "proxy_read_timeout 300s;" in config
assert "proxy_request_buffering off;" in config
assert "--force-recreate web" in script
+19
View File
@@ -0,0 +1,19 @@
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "apps" / "worker"))
from worker_app.core.asset_types import infer_mime_type_from_storage_key
def test_infer_mime_type_treats_mov_as_video():
assert infer_mime_type_from_storage_key("uploads/abc/DBLQ7915.MOV") == "video/quicktime"
def test_infer_mime_type_treats_common_video_extensions_as_video():
for filename in ["clip.mp4", "clip.m4v", "clip.avi", "clip.mkv", "clip.webm"]:
assert infer_mime_type_from_storage_key(f"uploads/abc/{filename}") == "video/mp4"
def test_infer_mime_type_keeps_unknown_files_as_image_placeholder():
assert infer_mime_type_from_storage_key("uploads/abc/photo.jpg") == "image/jpeg"