From c4e3ec920e3bcc0f57ffae03dce3c309a611eb08 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Tue, 19 Oct 2021 19:33:02 +0200 Subject: Fix error --- src/api/mastodon/index.ts | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/api/mastodon') diff --git a/src/api/mastodon/index.ts b/src/api/mastodon/index.ts index f3bf45c..3bfe9c8 100644 --- a/src/api/mastodon/index.ts +++ b/src/api/mastodon/index.ts @@ -22,6 +22,10 @@ export const client = got.extend({ export async function upload(buf: Buffer, filename: string) { const type = await fileType.fromBuffer(buf); + if (!type) { + throw new Error("Couldn't determine file type"); + } + const body = new FormData(); body.append("file", buf, { filename: `${filename}.${type.ext}`, contentType: type.mime }); -- cgit v1.2.3-70-g09d2