From cef5b5c455fc368243f6a9cedd7980ed4571a070 Mon Sep 17 00:00:00 2001 From: daniel-j Date: Fri, 8 Dec 2023 00:00:53 +0100 Subject: [PATCH] try fix epub on kindle for some clients --- index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 551fb1c..107b487 100644 --- a/index.js +++ b/index.js @@ -232,10 +232,14 @@ router.post('/upload', upload.single('file'), async ctx => { return } - const mimetype = ctx.request.file.mimetype + let mimetype = ctx.request.file.mimetype const type = await FileType.fromFile(ctx.request.file.path) + if (mimetype == "application/octet-stream" && type) { + mimetype = type.mime + } + if ((!type || !allowedTypes.includes(type.mime)) && !allowedTypes.includes(mimetype)) { flash(ctx, { message: 'Uploaded file is of an invalid type: ' + ctx.request.file.originalname + ' (' + (type? type.mime : 'unknown mimetype') + ')',