Finding the mime type

Trying to upload an xls file.

Shrine identifies the file as “Composite Document File V2 Document, corrupt: Can’t read SAT”, but running file --mime-type gives me application/, as expected.

Am I missing a configuration option?

Are you using the default :file analyzer for determine_mime_type plugin? If so, the results should not differ from using the file command directly. Do you get this when you call:


If yes, I would need a self-contained example the shows this behaviour, along with the XLS file.

Unfortunately, I cannot share the file.

I do get the corrupt message when using Shrine.determine_mime_type(io) on the command line.

Interestingly file --mime-type file.xls gives me the correct file type, but cat file.xls | file --mime-type - gives me the corruption message.

Other xls files work as expected. At this point, we’re prepared to chalk it up to the vagaries of mime-type detection on differing OSs and a possibility that the file is actually corrupt in some way.

It could be that the file command also takes the file extension into account when determining the MIME type, which it doesn’t have when we’re just piping file content. I also wanted to check whether you’ve made sure to open the XLS file in binary mode, but if piping in the shell produces the same error, then it’s probably not that.

Maybe you might have better luck using other MIME type analyzers, such as :marcel or :mimemagic. Other than that, the file might indeed be corrupt in some way.