feat: 모드팩 다운로드 API 추가
- GET /api/modpacks/:id/download: S3 URL로 리디렉션
This commit is contained in:
parent
3ab156cd56
commit
83820c3951
1 changed files with 23 additions and 0 deletions
|
|
@ -134,4 +134,27 @@ router.get("/modpacks", async (req, res) => {
|
|||
}
|
||||
});
|
||||
|
||||
// 모드팩 다운로드 API (S3 리디렉션)
|
||||
router.get("/modpacks/:id/download", async (req, res) => {
|
||||
try {
|
||||
const { id } = req.params;
|
||||
|
||||
const [rows] = await dbPool.query(`SELECT * FROM modpacks WHERE id = ?`, [
|
||||
id,
|
||||
]);
|
||||
if (rows.length === 0) {
|
||||
return res.status(404).json({ error: "모드팩을 찾을 수 없습니다" });
|
||||
}
|
||||
|
||||
const modpack = rows[0];
|
||||
const downloadUrl = `https://s3.caadiq.co.kr/minecraft/${modpack.file_key}`;
|
||||
|
||||
// Content-Disposition 헤더로 파일명 지정하여 리디렉션
|
||||
res.redirect(downloadUrl);
|
||||
} catch (error) {
|
||||
console.error("[API] 모드팩 다운로드 실패:", error.message);
|
||||
res.status(500).json({ error: "다운로드 실패" });
|
||||
}
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue