In java (jdk 1.6) is there a way to check a file is a valid xlsx without opening the entire file with POI or other API. Currently we use Apache POI in the project to open the file - basically we create a new XSSFWorkbook(inputStream) and if that throws an exception it is not a valid xlsx. However we found one xlsx file which is 8MB is taking 1GB memory to open for some reason and actually caused a production outage on our servers. We can not rely on the file extension as someone can take a file which is not xlsx like a php file and rename with xlsx extension. I'm looking for some option which has minimal memory impacts - ideally not opening the file at all.
Its too much of a risk if a single file upload can kill the server but we also still need to validate the file is in fact an xlsx.