Cập nhật avatar và chỉnh sửa thông tin người dùng
This commit is contained in:
@@ -907,6 +907,29 @@ router.put('/me/profile', protect, async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @route GET /api/assets/view_avatar/:filename
|
||||
* @desc Securely stream user avatar images
|
||||
* @access Public (No auth needed for avatars)
|
||||
*/
|
||||
router.get('/assets/view_avatar/:filename', (req, res) => {
|
||||
try {
|
||||
const filename = req.params.filename;
|
||||
const avatarPath = path.join(uploadDir, filename);
|
||||
|
||||
if (!fs.existsSync(avatarPath)) {
|
||||
return res.status(404).json({ message: 'Avatar not found' });
|
||||
}
|
||||
|
||||
res.sendFile(avatarPath, {
|
||||
maxAge: 2592000000, // 30 ngày
|
||||
headers: { 'Content-Type': 'image/jpeg' }
|
||||
});
|
||||
} catch (error) {
|
||||
res.status(500).json({ message: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @route GET /api/me/scenes
|
||||
* @desc Lấy danh sách các cảnh mẹ do người dùng tạo
|
||||
|
||||
Reference in New Issue
Block a user