From 33103cc452cce0c7b91853d5f5466c1702ee576d Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Sun, 10 Oct 2021 14:08:52 +0200 Subject: :bug: fix cdn --- util/src/util/cdn.ts | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) (limited to 'util/src') diff --git a/util/src/util/cdn.ts b/util/src/util/cdn.ts index 8d45f85f..4dd0078a 100644 --- a/util/src/util/cdn.ts +++ b/util/src/util/cdn.ts @@ -25,30 +25,15 @@ export async function uploadFile(path: string, file: Express.Multer.File) { return result; } -export async function handleFile( - path: string, - body?: string -): Promise< - | (string & { - id: string; - content_type: string; - size: number; - url: string; - }) - | undefined -> { +export async function handleFile(path: string, body?: string): Promise { if (!body || !body.startsWith("data:")) return undefined; try { const mimetype = body.split(":")[1].split(";")[0]; const buffer = Buffer.from(body.split(",")[1], "base64"); // @ts-ignore - const file = await uploadFile(path, { buffer, mimetype, originalname: "banner" }); - const obj = file.id; - for (const key in file) { - obj[key] = file[key]; - } - return obj; + const { id } = await uploadFile(path, { buffer, mimetype, originalname: "banner" }); + return id; } catch (error) { console.error(error); throw new HTTPError("Invalid " + path); -- cgit 1.4.1