-
-
Notifications
You must be signed in to change notification settings - Fork 636
xlsx mime type #149
Comments
Hmmm this is weird. Are you calling the |
No, I'm just using |
Oh I see. Then it makes sense, as an XLSX is simply a ZIP file with the "xlsx" extension. |
My use case is a generated xlsx file, that I have to serve afterwards. |
How did you create the other xlsx files? Excel? Which version of Excel? |
I know that |
Hmmm even with the file you sent me I have:
Looks like detecting the mime type is environment specific. |
Of course it is, it depends on the configuration of your magic. |
Here is a different try. Write a script called <?php
$finfo = new \finfo(FILEINFO_MIME_TYPE);
echo $finfo->file($argv[1]).PHP_EOL; With a such file, |
Cool! I can reproduce the issue :)
I don't have |
Hey @garak, After pulling my hair out for a few hours, I finally figured out why the mime type is wrong. It turns out the order in which the XML files gets added to the final ZIP file (an XLSX file being a ZIP file with the xlsx extension) matters for the heuristics used to detect types. Currently, files are added in this order:
The problem comes from inserting the "docProps" related files. It seems like the heuristic is to look at the first few bytes and check if it finds I'll try to fix this nicely |
Great! Hope to see a new tag released soon. |
I'm creating an xlsx file (e.g. using
Type::XLSX
).I expect to get a file with mime type
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
, instead I'm getting one withapplication/zip
.The text was updated successfully, but these errors were encountered: