.mp4 and .webm extensions could be audio or video
Opened this issue · 5 comments
Another method should be added to handle these cases.
References:
http://voice.firefallpro.com/2012/03/html5-audio-video-mime-types.html
http://www.iana.org/assignments/media-types/media-types.xhtml
This is true, but this project is primarily a mapping from extension to mime type. It's not possible in this setup to map a single extension to multiple mime types, so the most common is used.
A cross reference mapping of all possible mime types to all possible extensions would be interesting but would lose value for programmatic use.
Happy to accept alternative suggestions though.
Thanks for the input.
Sam
But my issue is related exactly to this primary goal: given the extension .mp4 I currently always get video/mp4, but this extension as a matter of fact could be used for audio/mp4 (as found on Facebook Messenger Platform Webhooks).
I first (naive) suggestion would be to add another method (like GetAllMimeTypes), returning an array of strings.
Usually you use the mapping when sending a stored file to the client in the content-type response header. What would you do with multiple possible mime types?
I'm happy to accommodate if reasonable, but I don't see the follow through to your request working toward your end goal (which I'm assuming.. what exactly are you doing?).
Thanks,
Sam
Sorry by the lack of details. I am integrating with Facebook Messenger Webhook where messages with media are sent with 2 properties only: a type (which could be image, audio, video or file) and an uri.
Previously I was just extracting the extension from this uri and applying to MimeTypeMap.GetMimeType in order to get the mime type for further processing - which is essentially the same scenario you described as the usual mapping situation. But I have received audio files with .mp4 extensions, which at this time return video/mp4 mime type by MimeTypeMap.
If MimeTypeMap could return both types all I will have to do is to check if the return has more than 1 mime type, and if so just match the type part with the one sent on Facebook's webrequest to continue with the correct mime type.
To handle this exceptional case I have added a specific check for mp4 extensions. It works, but it will be much more concise delegating all the mapping to only one place/component.
Regards.
Thanks for explaining. Your situation does make sense in how multiple types would be useful. I don't think it's a very common one that I think would complicate the mime-map dictionary if I tried to accommodate.
I'd suggest implementing something within your own project to handle this specific situation, or create your own fork of this project and make whatever changes are needed to support your needs.
Thanks for following up. Interesting.