get extension from mime type if not available

This commit is contained in:
Marc-Roig 2022-08-08 10:38:42 +02:00
parent 4de86c4927
commit 5a90357622

View File

@ -68,10 +68,9 @@ module.exports = ({ strapi }) => ({
async formatFileInfo({ filename, type, size }, fileInfo = {}, metas = {}) {
const fileService = getService('file');
let ext = '.' + extension(type);
// If it is a file , get the extension from the filename.
if (ext === '.bin') {
ext = path.extname(filename);
let ext = path.extname(filename);
if (!ext) {
ext = extension(type);
}
const basename = path.basename(fileInfo.name || filename, ext);
const usedName = fileInfo.name || filename;