Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.5] Add public getter method for MIME types to be able to use them. #20826

Merged
merged 1 commit into from
Aug 30, 2017

Conversation

mathieutu
Copy link
Contributor

For now, we can't use this array of mimetypes in our apps except from filename, and it's a bit too bad.
This PR adds a simple public method to benefit of it.

@taylorotwell
Copy link
Member

Please provide a code example of what you are referring to and what this makes possible.

@mathieutu
Copy link
Contributor Author

mathieutu commented Aug 30, 2017

If you want to see what is the MIME type of an extension:

return MimeType::get('psd') // image/vnd.adobe.photoshop

you can also need to have the extension from the MIME (I wondered to create a findExtension direct method too, but you tought me to make small PR 😅):

$mimes = MimeType::get();
return array_flip($mimes)['video/x-flv'] // flv

It's useful when you work with data-url scheme for example (you don't have the extension of the original file, in this case):

data:image/png;base64,iVBORw0KGgoAAA ANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4 //8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU 5ErkJggg==

@taylorotwell taylorotwell merged commit abdc31d into laravel:5.5 Aug 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants