summary refs log tree commit diff
path: root/util
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-10 14:08:52 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-10 14:08:52 +0200
commit2908544b271dcdf5fb3716b48c27d9b7b9506bb0 (patch)
tree1a210a00a9f2d479baceaa6e768fe5b6e95c8b84 /util
parentMerge branch 'master' into pr/LoboMetalurgico/424 (diff)
downloadserver-2908544b271dcdf5fb3716b48c27d9b7b9506bb0.tar.xz
:bug: fix cdn
Diffstat (limited to 'util')
-rw-r--r--util/src/util/cdn.ts21
1 files changed, 3 insertions, 18 deletions
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<string | undefined> {
 	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);