feat: 독립적인 파일 다운로드 페이지 구현
- React 앱과 완전히 독립된 HTML 페이지 생성 (/download) - URL 파라미터 검증 (key, expired_time) - 만료 시간 체크 및 적절한 화면 표시 - 사업자번호 입력 및 자동 포맷팅 (xxx-xxxxx-xx) - 파일 다운로드 기능 (테스트 모드 포함) - 반응형 디자인 및 모바일 최적화 - 클린 코드 및 모듈 패턴 적용 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
68
src/api/download-api.ts
Normal file
68
src/api/download-api.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import axios from 'axios';
|
||||
|
||||
interface DownloadValidationRequest {
|
||||
key: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
interface DownloadValidationResponse {
|
||||
success: boolean;
|
||||
downloadUrl?: string;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate download password and get download URL
|
||||
* @param key - UUID key from URL parameter
|
||||
* @param password - Business registration number (사업자번호)
|
||||
* @returns Promise with download URL if validation succeeds
|
||||
*/
|
||||
export async function validateDownloadPassword(
|
||||
key: string,
|
||||
password: string
|
||||
): Promise<DownloadValidationResponse> {
|
||||
try {
|
||||
const response = await axios.post<DownloadValidationResponse>(
|
||||
'/api/download/validate',
|
||||
{
|
||||
key,
|
||||
password,
|
||||
} as DownloadValidationRequest
|
||||
);
|
||||
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError(error)) {
|
||||
return {
|
||||
success: false,
|
||||
message: error.response?.data?.message || '비밀번호가 일치하지 않습니다.',
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
success: false,
|
||||
message: '오류가 발생했습니다. 다시 시도해 주세요.',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate secure download link
|
||||
* @param merchantId - Merchant ID
|
||||
* @param fileType - Type of file to download
|
||||
* @returns Promise with download key and URL
|
||||
*/
|
||||
export async function generateDownloadLink(
|
||||
merchantId: string,
|
||||
fileType: string
|
||||
): Promise<{ key: string; url: string }> {
|
||||
const response = await axios.post<{ key: string; url: string }>(
|
||||
'/api/download/generate',
|
||||
{
|
||||
merchantId,
|
||||
fileType,
|
||||
}
|
||||
);
|
||||
|
||||
return response.data;
|
||||
}
|
||||
Reference in New Issue
Block a user