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:
1 parent
e33962686e
commit
60298f6eeb
5 files changed
+511
-6
No files matched your search
@@ -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,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user