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

System.Net.Mime.MediaTypeNames missing types #1489

Closed
snebjorn opened this issue Oct 26, 2017 · 39 comments · Fixed by #86770
Closed

System.Net.Mime.MediaTypeNames missing types #1489

snebjorn opened this issue Oct 26, 2017 · 39 comments · Fixed by #86770
Assignees
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.Net
Milestone

Comments

@snebjorn
Copy link

https://github.com/dotnet/corefx/blob/3f0bd5d8c3d019ad8b1561395030a58bc38ddfe9/src/System.Net.Mail/ref/System.Net.Mime.cs#L44

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

@weitzhandler
Copy link
Contributor

weitzhandler commented Dec 11, 2017

Please implement this already!

See this and this.

@gtaylor1981
Copy link

See dotnet/corefx#26201 for application/json and application/xml

@sven5
Copy link

sven5 commented Jun 14, 2018

I'm currently dealing with file uploads.
It would be great to have MIME types for Office documents (Word, Excel).

@snebjorn
Copy link
Author

Perhaps System.Net.Mime.MediaTypeNames will share the same fate as System.Net.HttpStatusCode. Which is that it's considered dead and not to be used.

aspnet/Mvc#6997 (comment)

@coldacid
Copy link

Perhaps System.Net.Mime.MediaTypeNames will share the same fate as System.Net.HttpStatusCode. Which is that it's considered dead and not to be used.

aspnet/Mvc#6997 (comment)

Funny that MediaTypeNames or at least its inner classes are designed more or less the same as StatusCodes, the replacement for HttpStatusCode.

@GF-Huang
Copy link

GF-Huang commented Jul 9, 2019

2019 still no application/x-www-form-urlencoded.

@hezymal
Copy link

hezymal commented Sep 5, 2019

Maybe class MediaTypeNames and nested classes as partial?

@coldacid
Copy link

coldacid commented Sep 5, 2019

I don't think you can spread a partial type across multiple assemblies.

@CleytonGoncalves
Copy link

This issue has been marked as up-for-grabs, but we still need to wait for the API approval, is that correct?

@danmoseley
Copy link
Member

It's public API so strictly, yes (not sure whether dotnet/corefx#36365 got API approval). @wfurt can share how to best do that eg with a PR.

@wfurt
Copy link
Member

wfurt commented Sep 26, 2019

Let me ask around @danmosemsft. The list here seems more reasonable than dotnet/corefx#36365.

@karelz
Copy link
Member

karelz commented Oct 2, 2019

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.

@weitzhandler
Copy link
Contributor

BTW might of interest to subscribers: dotnet/csharplang#2849

@ahordijk
Copy link

With problemdetails, https://tools.ietf.org/html/rfc7807, implemented in .net core please add:

  • application/problem+json
  • application/problem+xml

@douglasg14b
Copy link

@karelz Is there a specific format example you have in mind for this proposal? What restrictions and limitations should someone interested in making a pull request be aware of?

@karelz
Copy link
Member

karelz commented Oct 13, 2019

PR is early. We need API proposal first, well thought through as suggested above: #1489 (comment)
The API proposal info is here: https://github.com/dotnet/runtime/blob/main/docs/project/api-review-process.md with good examples in form.
Usage data will be key in this one (does not have examples in linked process)

@karelz karelz transferred this issue from dotnet/corefx Jan 9, 2020
@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.Net untriaged New issue has not been triaged by the area owner labels Jan 9, 2020
@karelz karelz added api-suggestion Early API idea and discussion, it is NOT ready for implementation needs more info and removed untriaged New issue has not been triaged by the area owner labels Jan 9, 2020
@karelz karelz added this to the 5.0 milestone Jan 9, 2020
@karelz karelz added this to To do in Networking ramp-up via automation Jan 9, 2020
@karelz karelz modified the milestones: 5.0, Future Feb 22, 2020
@snebjorn
Copy link
Author

snebjorn commented Apr 7, 2021

Unable to find any usage data for MIME types. However Mozilla have a list of Common MIME types.

@markwhitaker
Copy link

If it's useful as a workaround, I've implemented lots of missing MIME types in a very lightweight NuGet package (NuGet, source). (An older version is also available as an MIT-licensed gist).

@Marusyk
Copy link
Member

Marusyk commented Sep 17, 2021

I need text/csv ))
Any plans?

@21r8390
Copy link

21r8390 commented Oct 22, 2021

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.

@oobayly
Copy link

oobayly commented Oct 27, 2021

I find it rather strange that the dotnet team are still insisting on collecting usage information in order to add something like image/png.

image

@21r8390
Copy link

21r8390 commented Oct 27, 2021

I find it rather strange that the dotnet team are still insisting on collecting usage information... @oobayly

As long as the MIME type does not exist, you cannot increase the number of usage... Genius idea! 😂

@AraHaan
Copy link
Member

AraHaan commented May 8, 2022

It's also missing the csv media type name as well.

@bgilner-rgg
Copy link

text/json
text/x-json
text/javascript

@AraHaan
Copy link
Member

AraHaan commented May 11, 2022

application/zlib-stream

@jacrys
Copy link

jacrys commented Jul 18, 2022

text/json text/x-json text/javascript

json isn't a text MIME type, it is an application type and is already in the API at MediaTypeNames.Application.Json. (Source: RFC 4627 & .NET 6 Docs)

text/x-json was never ratified, nor was text/javascript.

@ldeluigi
Copy link

Please add text/csv too. This issue is from 2017

@mmarinchenko
Copy link

mmarinchenko commented Feb 19, 2023

#1489 (comment)

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.

@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 wwwroot directories.

Additional sources are: IANA Media Types and ASP.NET Core FileExtensionContentTypeProvider.

The Proposal

Application

  • FormUrlEncoded = "application/x-www-form-urlencoded"
  • Json = "application/json"
  • JsonPatch = "application/json-patch+json"
  • JsonSeq = "application/json-seq"
  • Manifest = "application/manifest+json"
  • Octet = "application/octet-stream"
  • Pdf = "application/pdf"
  • ProblemJson = "application/problem+json"
  • ProblemXml = "application/problem+xml"
  • Rtf = "application/rtf"
  • Soap = "application/soap+xml"
  • Wasm = "application/wasm"
  • Xml = "application/xml"
  • XmlDtd = "application/xml-dtd"
  • XmlPatch = "application/xml-patch+xml"
  • Zip = "application/zip"

Font

  • Collection = "font/collection"
  • Otf = "font/otf"
  • Sfnt = "font/sfnt"
  • Ttf = "font/ttf"
  • Woff = "font/woff"
  • Woff2 = "font/woff2"

Image

  • Avif = "image/avif"
  • Bmp = "image/bmp"
  • Gif = "image/gif"
  • Icon = "image/x-icon"
  • Jpeg = "image/jpeg"
  • Png = "image/png"
  • Svg = "image/svg+xml"
  • Tiff = "image/tiff"
  • Webp = "image/webp"

Multipart

  • ByteRanges = "multipart/byteranges"
  • FormData = "multipart/form-data"

Text

  • Css = "text/css"
  • Csv = "text/csv"
  • Html = "text/html"
  • JavaScript = "text/javascript"
  • Markdown = "text/markdown"
  • Plain = "text/plain"
  • RichText = "text/richtext"
  • Rtf = "text/rtf"
  • Xml = "text/xml"

@wfurt
Copy link
Member

wfurt commented Feb 24, 2023

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.

@karelz
Copy link
Member

karelz commented Feb 25, 2023

@wfurt yeah, if you can bring it to Networking meeting first, let's check that we have "reasonability" agreement. Then we can push it through API review.
Thanks for help!

@wfurt wfurt self-assigned this Mar 18, 2023
@wfurt wfurt modified the milestones: Future, 8.0.0 Mar 18, 2023
@karelz
Copy link
Member

karelz commented Mar 21, 2023

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.

@AraHaan
Copy link
Member

AraHaan commented Mar 25, 2023

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.

Will this include adding zlib-stream to the class as ZlibStream (to let the people know to use the ZlibStream class in .NET to decompress the stream data)?

@wfurt
Copy link
Member

wfurt commented Mar 25, 2023

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/zlib and application/gzip so I'm note sure from where the -stream is coming. The mime type should be specific to the content not the implementation producing it, right?

@AraHaan
Copy link
Member

AraHaan commented Mar 26, 2023

I am not sure, it might have been a random case where I noticed an zlib-stream version of it.

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label May 25, 2023
Networking ramp-up automation moved this from To do to Done May 26, 2023
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label May 26, 2023
@dotnet dotnet locked as resolved and limited conversation to collaborators Jun 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.Net
Projects
Development

Successfully merging a pull request may close this issue.