resize image before storing (#831)

* resize image fn

* wip

* simplify transform

* comment

* fix

* rm log

* allow pass-through for non-base-64

Co-authored-by: Alex van Andel <[email protected]>
This commit is contained in:
Alex JohanssonandAlex van Andel authored and GitHub committed 2021-09-30 21:37:29 +01:00
1 parent e33962686e
commit 60298f6eeb
5 files changed
+511 -6

No files matched your search

+3 -1
View File
@@ -1,3 +1,4 @@
import { resizeBase64Image } from "@server/lib/resizeBase64Image";
import { pick } from "lodash";
import type { NextApiRequest, NextApiResponse } from "next";
@@ -13,6 +14,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
}
try {
const avatar = req.body.avatar ? await resizeBase64Image(req.body.avatar) : undefined;
await prisma.user.update({
where: {
id: session.user.id,
@@ -21,7 +23,6 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
...pick(req.body, [
"username",
"name",
"avatar",
"timeZone",
"weekStart",
"hideBranding",
@@ -29,6 +30,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
"completedOnboarding",
"locale",
]),
avatar,
bio: req.body.description,
},
});