fix frontend bug

This commit is contained in:
jaehwang committed 2026-09-08 15:57:35 +09:00
1 parent a18f7a5c8b
commit 9bb46f7004
10 files changed
+83 -21

No files matched your search

+16 -1
View File
@@ -5,6 +5,7 @@ SAS 토큰을 붙인 URL로 PUT 한 번. 경로 규칙은 부르는 쪽이 정
"""
import mimetypes
from pathlib import Path
from urllib.parse import quote
import httpx
@@ -60,12 +61,26 @@ def with_sas(url: str) -> str:
return url
async def upload_bytes(data: bytes, path: str, content_type: str | None = None) -> str:
def as_attachment(filename: str) -> str:
"""이 값이 붙은 blob은 브라우저가 열면 내려받기가 된다.
<a download>은 다른 출처에 안 먹어 완성본은 이 길로 간다.
한글 파일명은 RFC 5987 형식이라야 온전히 건너간다.
"""
return f"attachment; filename*=UTF-8''{quote(filename)}"
async def upload_bytes(data: bytes, path: str, content_type: str | None = None,
disposition: str | None = None) -> str:
"""path 예: playreel/nol_26007416/clip.mp4. 공개 URL을 돌려준다."""
if not settings.azure_blob_base_url or not settings.azure_blob_sas_token:
raise RuntimeError("AZURE_BLOB_BASE_URL / AZURE_BLOB_SAS_TOKEN 없음")
headers = {"Content-Type": content_type or guess_content_type(path), **BLOB_TYPE_HEADER}
if disposition:
# 헤더 이름이 Content-Disposition이면 이 요청 본문의 성격으로 읽힌다.
# blob 속성으로 저장되는 것은 x-ms- 쪽이다
headers["x-ms-blob-content-disposition"] = disposition
response = await get_client().put(upload_url(path), content=data, headers=headers)
if response.status_code not in (200, 201):
print(f"[blob] 업로드 실패 {response.status_code} {path}: {response.text[:300]}",