docs: 1-2단계 API 구현 세부사항 보충 (DB 접근, 에러 핸들링, import)
This commit is contained in:
parent
cb7e728349
commit
2e7cee0b84
@ -24,25 +24,30 @@ coldmail_briefing.py:207에서 document_id를 attachment에 전달하지만, Sla
|
||||
|
||||
### 1단계: skill-rag-file 다운로드 API 추가
|
||||
**파일**: skill-rag-file/app/api/download.py (신규)
|
||||
**참고**: upload.py:80-87 (storage_path 생성 로직)
|
||||
**구현**:
|
||||
- `@router.get("/download/{document_id}")`: UUID로 문서 조회
|
||||
- DB에서 TeamDocument.storage_path 가져오기 (upload.py:108 참고)
|
||||
- `FileResponse(storage_path, media_type="application/pdf")` 반환
|
||||
**등록**: skill-rag-file/app/main.py:55 이후 추가
|
||||
**import**: upload.py:1, 10, 12 참고 (FastAPI, get_db, TeamDocument)
|
||||
**router**: `@router.get("/download/{document_id}")`
|
||||
**DB 조회**: upload.py:60-65 패턴 사용
|
||||
- `select(TeamDocument).where(TeamDocument.id == document_id)`
|
||||
- `db.execute(stmt)`, `result.scalar_one_or_none()`
|
||||
- 없으면 HTTPException(404)
|
||||
**반환**: `FileResponse(document.storage_path, media_type="application/pdf")`
|
||||
**등록**: skill-rag-file/app/main.py:55 이후
|
||||
- `from app.api import upload, search, download`
|
||||
- `app.include_router(download.router, prefix="/api", tags=["download"])`
|
||||
|
||||
### 2단계: skill-slack 파일 업로드 API 추가
|
||||
**파일**: skill-slack/app/api/endpoints/files.py (신규)
|
||||
**참고**: lists.py:47-82 (엔드포인트 구조), slack_lists_service (서비스 패턴)
|
||||
**구현**:
|
||||
- `@router.post("/files/upload", dependencies=[Depends(verify_api_key)])`: UploadFile 받기
|
||||
- 파라미터: file (UploadFile), title (str), token (Optional[str])
|
||||
- WebClient(token).files_upload_v2(file=file.file, title=title) 호출
|
||||
- 반환: `{"file_id": str, "url_private": str}`
|
||||
**등록**: skill-slack/app/api/__init__.py 수정
|
||||
- 4번 줄: `from .endpoints import summary, digest, actions, messages, lists, files`
|
||||
- 13번 줄 이후: `router.include_router(files.router, tags=["Files"])`
|
||||
**import**: lists.py:4-9 참고 (FastAPI, settings, verify_api_key)
|
||||
- `from slack_sdk import WebClient` (test_lists_with_file.py:4)
|
||||
**router**: `@router.post("/files/upload", dependencies=[Depends(verify_api_key)])`
|
||||
**파라미터**: file (UploadFile), title (str), token (Optional[str])
|
||||
**업로드**: test_lists_with_file.py:18, 21-24 패턴
|
||||
- `client = WebClient(token or settings.SLACK_BOT_TOKEN)`
|
||||
- 임시 파일 저장 → `client.files_upload_v2(file=temp_path, title=title)`
|
||||
- 업로드 후 임시 파일 삭제
|
||||
**반환**: `{"file_id": result["file"]["id"], "url_private": result["file"]["url_private"]}`
|
||||
**에러**: HTTPException(400 or 500)
|
||||
**등록**: skill-slack/app/api/__init__.py:4, 13 수정
|
||||
|
||||
### 3단계: coldmail_briefing.py 통합
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user