ralouphie / mimey

PHP package for converting file extensions to MIME types and vice versa.
MIT License
324 stars 87 forks source link

Unexpected mime type for zip files #21

Open MaximilianKresse opened 4 years ago

MaximilianKresse commented 4 years ago

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?

peter279k commented 4 years ago

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

The zip and gzip are different MIME types.

peter279k commented 4 years ago

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

ralouphie commented 4 years ago

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.

peter279k commented 4 years ago

@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:

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

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

sybbear commented 4 years ago

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? :)

peter279k commented 4 years ago

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.

neilberry001 commented 2 years ago

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',
    ),