Archived from the Transloadit support forum. Originally posted on February 20, 2012; details may be outdated, see our docs for current behavior. Original thread
When I upload a PPTX file (from newer versions of Microsoft Powerpoint), the browser sends the correct content type:
However, when I view the assembly (e.g., https://transloadit.com/assemblies/view/REDACTED) on your web site, it lists “application/zip” as the content type. The incorrect “application/zip” is also what is being stored as the file’s content type in S3 when the S3 robot saves the file.
As you can imagine, this becomes a problem when a used tries to download the file again from S3. How can I get around the problem?
it seems our version of exiftool identifies the image to be a zip, that is the problem.
root@dev2:~# exiftool REDACTED
ExifTool Version Number : 8.56
File Name : REDACTED
Directory : .
File Size : 34 kB
File Modification Date/Time : 2012:02:21 10:26:44+00:00
File Permissions : rw-r–r–
File Type : ZIP
MIME Type : application/zip
Zip Required Version : 20
Zip Bit Flag : 0x0006
Zip Compression : Deflated
Zip Modify Date : 1980:01:01 00:00:00
Zip CRC : 0xb0bbdac2
Zip Compressed Size : 497
Zip Uncompressed Size : 3259
Zip File Name : [Content_Types].xml
root@dev2:~#
I’ll make sure we upgrade exiftool soonish. I have already tested it on a newer version and there the mime type is detected fine.
Tim, a PPTX file is actually a zip file, as far as the magic numbers are concerned. That is part of the problem here.
Perhaps the storage robots should trust and use the Content-Type given by the uploading browser, even though the image processing robots use the magic numbers to see if the file is applicable to them. Would that work?
The phrases “the real mime type based on the magic numbers” and “the mime found in the file” are misnomers because the client uploading the file in general has more information available than just the magic numbers when deciding which content type to send. In particular, any Mac or Windows machine with Microsoft Office installed will be able to assign the correct content types to docx, xlsx, and pptx documents, even though all of these formats are zip files.
I think the correct thing to do is to use exiftools and magic numbers when deciding whether a particular image processing robot can handle a file, but to pass along the original content type when sending the original file to S3.
Setting the content type with the “headers” parameter is not an appealing solution because the user could upload files of any type (they are attachments to messages) and the file being uploaded does not go through my server. (After all, avoiding having to process files on my server is the main reason I use transloadit.)
I realized that the version of exiftool I tested this against was 8.76. That could extracted “application/vnd.openxmlformats-officedocument.presentationml.presentation”. We have now upgraded to 8.79, which extracts “application/zip” again, so there is some confusion in exiftool as well.
I will discuss within the team if it’s a good idea to pass on the original content-type instead of relying completely on magic numbers/exiftools and will then get back to you.
sorry for the delay. We have upgraded our meta parsing tools and the mime type should be extracted fine now. Please confirm this when you get a chance.