1

I have a Spring application that reads XLS and XLSX files with Apache POI. In my pc (Windows 8, Firefox, LibreOffice and Microsoft oficce installed). With both types of Excel files correctly detects the type "application / vnd.ms-excel" and "application / vnd.openxmlformats-officedocument.spreadsheetml.sheet" respectively.

In another pc with windows xp and installed libreoffice (not microsoft office), to send me excel files detected as "application / octet-stream". By contrast, with the other files it works well, txt, pdf, jpg ... until ods.

To send the file used a MultipartFile and getContentType ().

My question is why is sending me the wrong type. Where does the data type? The operating system from being sent; perhaps the problem can be by not having Microsoft Office installed? If so unreliable validate it depends on the type of computer from which it is sent.

oscar
  • 1,636
  • 6
  • 31
  • 59
  • If you are not having Microsoft Office also you can send and receive those files. – SatyaTNV Jul 30 '15 at 16:55
  • Do you mean that the file upload gives you the wrong MIME type for the uploaded file? Yes, it's completely unreliable. It's dependent on the operating system and browser and can be hacked. You should detect the file type after it is uploaded, if you want to be safe. – RealSkeptic Jul 30 '15 at 17:21
  • I detect the file type on a Controller, on the server side. I mean it sends the wrong type for not having the program that opens it. In this case the Microsoft Office. If so it is not a very reliable test, because if I do not have the program that opens detect the file as binary as "application / octet-stream". – oscar Jul 30 '15 at 17:31

0 Answers0