feat: [worker] 중간검사 성적서 이미지 presigned URL 지원
- getImageUrl()에서 image_url(presigned URL) 우선 사용 - SectionImage 타입에 image_url 추가
This commit is contained in:
@@ -68,15 +68,13 @@ interface TemplateInspectionContentProps {
|
||||
|
||||
// ===== 유틸 =====
|
||||
|
||||
/** API 저장소 이미지 URL 생성 — file_id 기반 R2 프록시 사용 */
|
||||
function getImageUrl(fileId?: number | null, path?: string | null): string {
|
||||
// file_id가 있으면 프록시 경로 사용
|
||||
/** API 저장소 이미지 URL 생성 — image_url(presigned URL) 우선 사용 */
|
||||
function getImageUrl(fileId?: number | null, path?: string | null, imageUrl?: string | null): string {
|
||||
if (imageUrl) return imageUrl;
|
||||
if (fileId) return `/api/proxy/files/${fileId}/view`;
|
||||
// fallback: 레거시 경로
|
||||
if (!path) return '';
|
||||
if (path.startsWith('http://') || path.startsWith('https://')) return path;
|
||||
if (path.startsWith('/api/proxy/')) return path;
|
||||
return path;
|
||||
if (path.startsWith('http')) return path;
|
||||
return '';
|
||||
}
|
||||
|
||||
/** field_values.reference_attribute에서 작업 아이템의 실제 치수를 resolve */
|
||||
@@ -284,10 +282,10 @@ function buildBendingProducts(order: WorkOrder): BendingProduct[] {
|
||||
}
|
||||
|
||||
// ===== 이미지 섹션 컴포넌트 (onError 핸들링) =====
|
||||
function SectionImage({ section }: { section: { id: number; title?: string; name?: string; image_path?: string | null; file_id?: number | null } }) {
|
||||
function SectionImage({ section }: { section: { id: number; title?: string; name?: string; image_path?: string | null; file_id?: number | null; image_url?: string | null } }) {
|
||||
const [imgError, setImgError] = useState(false);
|
||||
const title = section.title || section.name || '';
|
||||
const url = (section.file_id || section.image_path) ? getImageUrl(section.file_id, section.image_path) : '';
|
||||
const url = (section.image_url || section.file_id || section.image_path) ? getImageUrl(section.file_id, section.image_path, section.image_url) : '';
|
||||
|
||||
return (
|
||||
<div className="mb-3">
|
||||
|
||||
Reference in New Issue
Block a user