runtime: System.Net.Mime.MediaTypeNames missing types
I tried using System.Net.Mime.MediaTypeNames in my asp net core api to remove “magic strings”
[Consumes(System.Net.Mime.MediaTypeNames.Application...)]
public IActionResult Post(...)
{ ... }
But it’s missing quite a few MIME types.
These come to mind:
text/css text/javascript
application/json application/json-patch+json application/xml application/javascript application/x-www-form-urlencoded
multipart/form-data multipart/byteranges
image/png image/bmp image/webp image/svg+xml
audio/midi audio/mpeg audio/webm audio/ogg audio/wav
video/webm video/ogg
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 88
- Comments: 39 (17 by maintainers)
Commits related to this issue
- Use sparse checkout for LLVM (#1489) Shaves down the clone/checkout to ~45 seconds. — committed to MichalStrehovsky/runtime by MichalStrehovsky 3 years ago
@karelz I am looking at the API review process you linked above, which step did this issue reach? Step one is someone creating an issue (this issue), step two is for the team to assign an owner, why hasn’t that happened yet?
Here is my proposal for the common mime types that I believe should exist under the System.Net.Mime.MediaTypeNames namespace. I have checked the existing ones in the list below. I also went with the assumption that mime types of executable files will not be added, is that fair? Maybe not.
Proposal
System.Net.Mime.MediaTypeNames.Text
System.Net.Mime.MediaTypeNames.Application
System.Net.Mime.MediaTypeNames.Image
Additional Categories
System.Net.Mime.MediaTypeNames.Multipart
System.Net.Mime.MediaTypeNames.Font
System.Net.Mime.MediaTypeNames.Video
System.Net.Mime.MediaTypeNames.Audio
Sourced from IANA - Media Types with the help of Mozilla to pick some common mime types.
If I have missed anything that you believe is useful, add it in a comment.
https://github.com/dotnet/runtime/issues/1489#issuecomment-537625716
@karelz I can agree that the audio, video, and office mime types have special uses and are not found in every application. But can we start with the file types used in the ASP.NET Core project templates, with the addition of related and some other well-known formats? I found most of the font and image formats there in the
wwwrootdirectories.Additional sources are: IANA Media Types and ASP.NET Core FileExtensionContentTypeProvider.
The Proposal
Application
Font
Image
Multipart
Text
Triage: The team discussed it on Thu 3/16. There was general agreement with the latest proposal - thank you @mmarinchenko! @wfurt will update the proposal into form ready for API review and mark it as such. We should be able to get it into 8.0 without any troubles.
With problemdetails, https://tools.ietf.org/html/rfc7807, implemented in .net core please add:
The proposed list above seems quite reasonable. I can try to take it through API review @karelz. While I personally see the benefit small, the effort is also somewhat small and we get help from the community.
See dotnet/corefx#26201 for
application/jsonandapplication/xmlI need text/csv )) Any plans?
Triage: We are open to add a few of the MIME type enums. Next step: Create proposal with most used ones (with some links to usage ideally) and with names how they should be exposed.
Please implement this already!
See this and this.
I was not planning to @AraHaan. Do you have example of public sites using it or is that something you applications do internally? https://www.rfc-editor.org/rfc/rfc6713 shows
application/zlibandapplication/gzipso I’m note sure from where the-streamis coming. The mime type should be specific to the content not the implementation producing it, right?It’s also missing the csv media type name as well.
This error has been open since 2017. It’s such a small thing to add these guys. When will PNG come?
Moreover, @Bilal-io’s list is no longer correct… See this for an updatet version.
text/json text/x-json text/javascript
As long as the MIME type does not exist, you cannot increase the number of usage… Genius idea! 😂
I find it rather strange that the dotnet team are still insisting on collecting usage information in order to add something like
image/png.Unable to find any usage data for MIME types. However Mozilla have a list of Common MIME types.
@Bilal-io thanks for your proposal with names! Were you able to get some information about the usage of each of them? (as mentioned above - https://github.com/dotnet/runtime/issues/1489#issuecomment-541385535 https://github.com/dotnet/runtime/issues/1489#issuecomment-537625716) I have to admit some of these are not known to me. For some I would expect they are on decline these days (e.g. Midi?) … some usage data would make decisions here easier.
Regarding your question:
You are right that we deviate from the process a bit – unless the API is super-active, we consider the area owners to be the owners (though not assigned explicitly). In case of Networking area, it is the members of our Networking team (incl. myself). Once API is ready, we discuss proposals in our team meeting to get more thoughts before marking it ready for API review. Also note that in principal we try to not assign issues unless someone works on them actively (otherwise we would be back in place where people had hundred and more issues assigned to them – which made assignments useless). Hopefully that makes sense …
I’m currently dealing with file uploads. It would be great to have MIME types for Office documents (Word, Excel).