Fb2 UploadedFile mimetype on different OSes not the same

16 views Asked by At

I write file uploading mechanism. In my case I upload books. All other extensions (and mimetypes) are uploaded good (pdf, djvu, zip, epub, doc, rtf) both on Ubuntu 22 and Windows 11, but fb2 have a weird behavior only on Windows 11 (on Ubuntu it uploads good)... On frontend I use axios and FormData. Here is the code:

let data = new FormData()
if (bookFiles.value?.files[0]) {
    _.each(bookFiles.value?.files, function (f) {
        data.append("bookFiles[]", f)
    })
}

Nothing special.

On backend I use Laravel. As I said, When I upload pdf, djvu, zip, epub, doc, rtf all looks the same on Windows and Ubuntu (mimetype, extension, etc.) But fb2...

On both OSes I use Google Chrome.

Here is the code and output when I upload the same fb2 file:

// Code
/** @var $uploadedFile \Illuminate\Http\UploadedFile */
\Log::debug($uploadedFile->clientExtension());
\Log::debug($uploadedFile->getClientOriginalName());
\Log::debug($uploadedFile->getClientOriginalExtension());
\Log::debug($uploadedFile->getClientMimeType());
\Log::debug($uploadedFile->getMimeType());

// Output

// Ubuntu
[2024-03-19 21:29:17] local.DEBUG: fb2  
[2024-03-19 21:29:17] local.DEBUG: name.fb2  
[2024-03-19 21:29:17] local.DEBUG: fb2  
[2024-03-19 21:29:17] local.DEBUG: application/x-fictionbook+xml  
[2024-03-19 21:29:17] local.DEBUG: text/xml 

// Windows
[2024-03-19 21:28:31] local.DEBUG: bin  
[2024-03-19 21:28:31] local.DEBUG: name.fb2  
[2024-03-19 21:28:31] local.DEBUG: fb2  
[2024-03-19 21:28:31] local.DEBUG: application/octet-stream  
[2024-03-19 21:28:31] local.DEBUG: text/xml

What nonsense?

0

There are 0 answers