try fix epub on kindle for some clients

This commit is contained in:
daniel-j
2023-12-08 00:00:53 +01:00
parent d0fa3da1b1
commit cef5b5c455

View File

@@ -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') + ')',