mimey icon indicating copy to clipboard operation
mimey copied to clipboard

Unexpected mime type for zip files

Open MaximilianKresse opened this issue 4 years ago • 7 comments

Code

(new \Mimey\MimeTypes())->getMimeType('zip');

Expected result

'application/zip'

Actual result

'application/x-gzip'

This wrong mime type means that e.g. Firefox and Chrome handle the file as gzip instead of a zip file and actively renaming the file. The problem is probably the order in the default configuration: https://github.com/ralouphie/mimey/blob/develop/mime.types.php#L34

Is there a reason for this order or is this a bug?

MaximilianKresse avatar Mar 10 '20 13:03 MaximilianKresse

That's a good catch I think and it should be fixed :).

The zip and gzip are different MIME types.

peter279k avatar Mar 10 '20 14:03 peter279k

@ralouphie, do you have any idea about this :)?

peter279k avatar Mar 23 '20 16:03 peter279k

This repository is meant to be a wrapper for httpd's mime types mapping. If a different mapping is needed, please leverage the custom mappings capability described in the documentation.

ralouphie avatar Mar 24 '20 00:03 ralouphie

@ralouphie, thanks for your reply.

According to the httpd mime type doc, it seems that this zip is different mime types.

They're as follows:

  • application/zip zip
  • # application/gzip

Do you mean the # application/gzip is customized mapping?

If yes, and I think you're right. And this issue will be closed :).

peter279k avatar Mar 24 '20 01:03 peter279k

Hi @ralouphie According to the httpd mime doc @peter279k mentioned, mime type for zip extension should be application/zip zip files are widespread and are important part of web services, so I see it as important to resolve.

Would you let us know what's needed to help progress resolution of this issue, a PR? :)

sybbear avatar Nov 25 '20 22:11 sybbear

It seems that the repository owner doesn't concern this PR for about whiles.

And I think it should add some collaborator on this repository.

peter279k avatar Nov 26 '20 06:11 peter279k

Ran into this issue also as the method forces the value at ZERO pointer.

https://github.com/ralouphie/mimey/blob/develop/src/MimeTypes.php#L52

The non-standard x-gzip should arguably be at the end of this array or advised use of getAllMimeTypes in all cases.

https://github.com/ralouphie/mimey/blob/develop/mime.types.php#L32

    'zip' => 
    array (
      0 => 'application/x-gzip',
      1 => 'application/zip',
    ),

neilberry001 avatar May 18 '22 13:05 neilberry001