PosInformatique.Foundations.MediaTypes 1.3.0-rc.3

Prefix Reserved
This is a prerelease version of PosInformatique.Foundations.MediaTypes.
There is a newer version of this package available.
See the version list below for details.
dotnet add package PosInformatique.Foundations.MediaTypes --version 1.3.0-rc.3
                    
NuGet\Install-Package PosInformatique.Foundations.MediaTypes -Version 1.3.0-rc.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PosInformatique.Foundations.MediaTypes" Version="1.3.0-rc.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PosInformatique.Foundations.MediaTypes" Version="1.3.0-rc.3" />
                    
Directory.Packages.props
<PackageReference Include="PosInformatique.Foundations.MediaTypes" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PosInformatique.Foundations.MediaTypes --version 1.3.0-rc.3
                    
#r "nuget: PosInformatique.Foundations.MediaTypes, 1.3.0-rc.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PosInformatique.Foundations.MediaTypes@1.3.0-rc.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PosInformatique.Foundations.MediaTypes&version=1.3.0-rc.3&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=PosInformatique.Foundations.MediaTypes&version=1.3.0-rc.3&prerelease
                    
Install as a Cake Tool

PosInformatique.Foundations.MediaTypes

NuGet version NuGet downloads

Introduction

PosInformatique.Foundations.MediaTypes provides a lightweight way to represent media types (MIME types) in .NET. It offers an immutable MimeType value object, a set of well-known media types, helpers for mapping between file extensions and media types, and a few convenience extension methods.

Install

You can install the package from NuGet:

dotnet add package PosInformatique.Foundations.MediaTypes

Features

  • Immutable MimeType value object (type/subtype, e.g. application/json, image/png).
  • Parsing and safe parsing from string (Parse / TryParse).
  • Provides IFormattable and IParsable<T> for seamless integration with .NET APIs
  • Resolve a MimeType from a file extension (with or without leading dot).
  • Resolve a default file extension from a MimeType.
  • Set of common application/* and image/* media types.
  • Simple extension methods, e.g. IsPdf() and IsImage().

Usage

Parsing media types

using PosInformatique.Foundations.MediaTypes;

var json = MimeType.Parse("application/json");
Console.WriteLine(json.Type);    // "application"
Console.WriteLine(json.Subtype); // "json"

if (MimeType.TryParse("image/png", out var png))
{
    Console.WriteLine(png); // "image/png"
}

Well-known media types

using PosInformatique.Foundations.MediaTypes;

var pdf = MimeTypes.Application.Pdf;   // application/pdf
var docx = MimeTypes.Application.Docx; // application/vnd.openxmlformats-officedocument.wordprocessingml.document
var jpeg = MimeTypes.Image.Jpeg;       // image/jpeg

From file extension to media type

using PosInformatique.Foundations.MediaTypes;

var pdfFromExt = MimeType.FromExtension(".pdf"); // application/pdf
var pngFromExt = MimeType.FromExtension("png");  // image/png

// Unknown extensions fall back to application/octet-stream
var unknown = MimeType.FromExtension(".unknown"); // application/octet-stream

From media type to default file extension

using PosInformatique.Foundations.MediaTypes;

var pdf = MimeTypes.Application.Pdf;
var pdfExtension = pdf.GetExtension(); // ".pdf"

var webp = MimeTypes.Image.WebP;
var webpExtension = webp.GetExtension(); // ".webp"

Extension methods

using PosInformatique.Foundations.MediaTypes;

var mimeType = MimeTypes.Application.Pdf;

if (mimeType.IsPdf())
{
    Console.WriteLine("This is a PDF document.");
}

var image = MimeTypes.Image.Png;
if (image.IsImage())
{
    Console.WriteLine("This is an image type.");
}

var drawing = MimeTypes.Image.Dwg;
if (drawing.IsAutoCad())
{
    Console.WriteLine("This is an AutoCAD drawing type.");
}

API overview

MimeType

  • Immutable value object representing type/subtype.
  • Implements IEquatable<MimeType> and IParsable<MimeType>.
  • Main members:
    • string Type { get; }
    • string Subtype { get; }
    • static MimeType Parse(string s)
    • static MimeType Parse(string s, IFormatProvider? provider)
    • static bool TryParse(string? s, out MimeType? result)
    • static bool TryParse(string? s, IFormatProvider? provider, out MimeType? result)
    • static MimeType FromExtension(string extension)
    • string GetExtension()

MimeTypes

Provides common media types and mapping helpers.

  • MimeTypes.Application

    • OctetStream (application/octet-stream)
    • Pdf (application/pdf)
    • Docx (application/vnd.openxmlformats-officedocument.wordprocessingml.document)
  • MimeTypes.Image

    • Bmp (image/bmp)
    • Dxf (image/x-dxf)
    • Dwg (image/x-dwg)
    • Jpeg (image/jpeg)
    • Png (image/png)
    • Svg (image/svg+xml)
    • Tiff (image/tiff)
    • WebP (image/webp)

MimeTypeExtensions

  • bool IsAutoCad(this MimeType mimeType)
  • bool IsImage(this MimeType mimeType)
  • bool IsPdf(this MimeType mimeType)
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on PosInformatique.Foundations.MediaTypes:

Package Downloads
PosInformatique.Foundations.Emailing

Provides a lightweight, template-based emailing infrastructure for .NET. Allows registering strongly-typed email templates, instantiating emails from models, and sending them through pluggable providers (e.g. Azure Communication Service).

PosInformatique.Foundations.MediaTypes.Json

Provides a lightweight and immutable MimeType value object to represent media types (MIME types) in .NET. Includes parsing, safe parsing, well-known application/* and image/* media types, and helpers to map between file extensions and media types.

PosInformatique.Foundations.MediaTypes.EntityFramework

Provides Entity Framework Core integration for the MimeType value object. Enables seamless mapping of MIME types as strongly-typed properties in Entity Framework Core entities, with safe conversion to string.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.4.0-rc.3 79 10/14/2026
1.4.0-rc.2 105 10/6/2026
1.4.0-rc.1 84 10/5/2026
1.3.0 231 10/2/2026
1.3.0-rc.4 101 9/29/2026
1.3.0-rc.3 96 9/28/2026
1.3.0-rc.2 98 9/25/2026
1.3.0-rc.1 115 9/23/2026
1.2.0 255 8/18/2026
1.1.0 268 3/30/2026
1.0.0 544 11/19/2025
Loading failed

1.0.0
 - Initial release with strongly-typed MimeType value object.

1.3.0
 - Added support for SVG image MIME type.