From 820d79c8ac7ba144d9357320c49b85b980387d43 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 21 May 2019 09:53:03 +0200 Subject: Fix OGG bug with firefox --- server/helpers/express-utils.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/server/helpers/express-utils.ts b/server/helpers/express-utils.ts index e0a1d56a5..00f3f198b 100644 --- a/server/helpers/express-utils.ts +++ b/server/helpers/express-utils.ts @@ -74,7 +74,18 @@ function createReqFiles ( }, filename: async (req, file, cb) => { - const extension = mimeTypes[ file.mimetype ] || extname(file.originalname) + let extension: string + const fileExtension = extname(file.originalname) + const extensionFromMimetype = mimeTypes[ file.mimetype ] + + // Take the file extension if we don't understand the mime type + // We have the OGG/OGV exception too because firefox sends a bad mime type when sending an OGG file + if (fileExtension === '.ogg' || fileExtension === '.ogv' || !extensionFromMimetype) { + extension = fileExtension + } else { + extension = extensionFromMimetype + } + let randomString = '' try { -- cgit v1.2.3