import path from 'path'; import { fileURLToPath } from 'url'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); export async function getProfilePicture(req, res) { const file = req.params.file; const filePath = path.join(__dirname, '../uploads/profiles', file); try { res.sendFile(filePath, (err) => { if (err) { console.error("Error sending profile picture:", err); res.status(404).json({ error: "Profile picture not found." }); } else { } }); } catch (error) { console.error("Error fetching profile picture:", error); res.status(500).json({ error: "Internal server error while fetching profile picture." }); } } export async function getThumbnail(req, res) { const file = req.params.file; const filePath = path.join('/app/app/uploads/thumbnails', file); try { res.sendFile(filePath, (err) => { if (err) { console.error("Error sending thumbnail:", err); res.status(404).json({ error: "Thumbnail not found." }); } else { } }); } catch (error) { console.error("Error fetching thumbnail:", error); res.status(500).json({ error: "Internal server error while fetching thumbnail." }); } } export async function getVideo(req, res) { const file = req.params.file; const filePath = path.join('/app/app/uploads/videos', file); try { res.sendFile(filePath, (err) => { if (err) { console.error("Error sending video:", err); } else { } }); } catch (error) { console.error("Error fetching video:", error); res.status(500).json({error: "Internal server error while fetching video."}); } }