feat(image): metadata support image mime type (#2026)

This commit is contained in:
Zong
2024-07-14 23:25:16 +08:00
committed by GitHub
parent dd2a9bdee5
commit 090c880860
3 changed files with 8 additions and 5 deletions

View File

@@ -10,9 +10,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
await connectToDatabase();
const { id } = req.query as { id: string };
const binary = await readMongoImg({ id });
const { binary, metadata } = await readMongoImg({ id });
res.setHeader('Content-Type', guessBase64ImageType(binary.toString('base64')));
res.setHeader('Content-Type', metadata?.mime ?? guessBase64ImageType(binary.toString('base64')));
res.send(binary);
} catch (error) {
jsonRes(res, {