R2 저장소 구조
Cloudflare R2에 저장되는 파일의 경로 구조를 정리합니다.
파일 경로 규칙
모든 파일은 다음 형태로 저장됩니다:
{prefix}/{ms_timestamp}_{safe_filename}
prefix: 기능별 저장 경로
ms_timestamp: 업로드 시점의 밀리초 타임스탬프
safe_filename: 특수문자가 정제된 파일명
전체 경로 구조
companies/{company_id}/sites/{site_id}/
│
├── tasks/{task_id}/
│ ├── details_attachments/ # 작업 상세/공지 첨부파일
│ └── files/{group_name}/ # 작업 파일 (그룹별)
│
├── material_supplier/{supplier_id}/
│ └── files/ # 자재 공급자 파일
│
├── other_expenses/{expense_id}/
│ └── items/{item_id}/files/ # 기타비용 항목 파일
│
├── safe_documents/{document_id}/ # 안전 문서 파일
│
├── safety_agreements/{UID}/ # 무사고 동의서
│
├── suggestions/{suggestion_id}/ # 건의사항 첨부
│
├── emergency_alert/{alert_id}/ # 긴급 알림 첨부
│
├── suspension_works/{work_id}/ # 작업중지 첨부 (통지서/보고서)
│
├── temp_files/ # 임시 파일
│
└── drive/ # 드라이브 파일
경로별 상세
작업 관리
| 경로 |
설명 |
업로드 토큰 함수 |
tasks/{task_id}/details_attachments/ |
작업 상세 첨부파일 |
get_task_details_attachment_upload_token |
tasks/{task_id}/details_attachments/ |
작업 공지 첨부파일 |
get_task_notice_attachment_upload_token |
tasks/{task_id}/files/{group_name}/ |
작업 파일 (그룹별) |
get_task_attachment_upload_token |
재무 관리
| 경로 |
설명 |
업로드 토큰 함수 |
material_supplier/{supplier_id}/files/ |
자재 공급자 파일 |
get_material_upload_token |
other_expenses/{expense_id}/items/{item_id}/files/ |
기타비용 항목 파일 |
get_other_expense_item_upload_token |
안전 관리
| 경로 |
설명 |
업로드 토큰 함수 |
safe_documents/{document_id}/ |
안전 문서 다운로드 |
get_safe_document_download_token |
safe_documents/{safe_doc_id}/ |
안전 문서 업로드 |
get_safety_agreement_upload_token |
safety_agreements/{UID}/ |
무사고 동의서 |
get_safety_agreement_upload_token |
suggestions/{suggestion_id}/ |
건의사항 첨부 |
get_suggestion_upload_token |
emergency_alert/{alert_id}/ |
긴급 알림 첨부 |
get_emergency_alert_upload_token |
suspension_works/{work_id}/ |
작업중지 통지서/보고서 |
get_suspension_work_notice_upload_token 외 |
기타
| 경로 |
설명 |
업로드 토큰 함수 |
temp_files/ |
임시 파일 |
get_temp_file_upload_token |
드라이브
| 경로 |
설명 |
업로드 토큰 함수 |
drive/ |
드라이브 파일 (플랫 저장) |
get_drive_file_upload_token |
Info
드라이브 파일은 R2에서 폴더를 구분하지 않고 플랫하게 저장됩니다.
폴더 구분은 Firestore files 컬렉션의 related_doc_id 필드로 관리합니다.