FTTLib.dll 1.1.7

dotnet add package FTTLib.dll --version 1.1.7                
NuGet\Install-Package FTTLib.dll -Version 1.1.7                
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="FTTLib.dll" Version="1.1.7" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FTTLib.dll --version 1.1.7                
#r "nuget: FTTLib.dll, 1.1.7"                
#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.
// Install FTTLib.dll as a Cake Addin
#addin nuget:?package=FTTLib.dll&version=1.1.7

// Install FTTLib.dll as a Cake Tool
#tool nuget:?package=FTTLib.dll&version=1.1.7                

FTT Logo File Type Translator (FTT)

NuGet version (FTTLib) NuGet Downloads npm PyPI CodeQL

A library of helper methods for your .Net, Javascript or Python projects to get mime types and general file category

Releases

Available as a nuget package, npm package, or PyPI package

1.1.7 - Updated sources, optimized generated code to be smaller and to be easier to diff future versions
1.1.5 - Updated sources, adds many modern file types and updates/eliminates some legacy mime types
1.1.4 - Multi-framework targeting nuget package
1.1.3 - Updated sources, Notably the mime type for .js is now text/javascript instead of application/javascript according to the IANA standard specification
1.1.2 - Updated sources, Initial python release
1.1.1 - Updated sources, switched to .netstandard runtime
1.1.0 - Updated sources, added PDF, Presentation, and Spreadsheet file categories - formerly part of Document
1.0.3 - Initial public release

Examples

Install
dotnet add package FTTLib.dll
Import the library
using FTTLib;
When you need to know the mime type of a file based on its extension.
string mimeType = FTT.GetMimeType(@"Path\To\My\File.doc");
Console.WriteLine(mimeType);

mimeType = FTT.GetMimeType(@"Path\To\My\File.docx");
Console.WriteLine(mimeType);

>  application/msword
>  application/vnd.openxmlformats-officedocument.wordprocessingml.document
When you need to know the file type category of a file based on its extension.
FileCategory category = FTT.GetFileCategory(@"Path\To\My\File.docx");
Console.WriteLine(category);

category = FTT.GetFileCategory(@"Path\To\My\File.jpg");
Console.WriteLine(category);

>  Document
>  Image
When you need to know the preferred file extension for a file based on its mime type.
string[] extensions = FTT.GetMimeTypeFileExtensions("text/csv");
Console.WriteLine(extensions[0]);

>  csv

Design

This library is designed along the following tenets:

  • No external dependencies
  • No file system access
  • Small memory footprint
  • Simple static methods (no extension methods and no instantiatable classes)
  • Case-insensitive
  • Portable - works in applications targeting any CLR

File Categories

File media types are broken down into relatively few categories. Sub-categories may be considered in a future release according to information on Wikipedia Here are the guidelines that determine a file's category

  • Archive: any file that can be extracted into several files
  • Audio: any file that can only contain an audio stream
  • Binary: any file that is unclassified or does not have a text representation
  • Code: any file that contains instructions that are compilable or machine-readable
  • Document: any file that is designed for conveying structured information between people
  • Image: any file that can only contain a single image or series of images
  • PDF: any file that is considered a document archive format
  • Presentation: any file that is designed for electronic presentations consisting of a series of separate pages or slides
  • Spreadsheet: any file in which data is arranged in rows and columns and can be manipulated and used in calculations
  • Text: any file that is not classified under another category and is not binary
  • Video: any file that is designed to be a container for a video stream

Known Limitations

  • Even though a mime type to file extension mapping is not necessarily one-to-one, the most common should be returned by the library
  • This library does not provide file sniffing capabilities - in other words, if you have a file and you want to verify the contents are of a specific type, look elsewhere. FTT only uses the file name with an extension. That capability may be added in a future release.
  • The only file categories presently considered are Archive, Audio, Binary, Code, Document, Image, PDF, Presentation, Spreadsheet, Text, and Video. Binary is the default if there is no match in the database.

Sources

While it is unrealistic to expect this library to provide a comprehensive list with all the file types the world has to offer, it would be nice if we could get close. Generally, if the file type is even remotely common, it is listed in one of the sources. You can submit a bug report for a file type that is missing or that you think should be added. You will have to include a reputable source as well.

Information sources for this library are provided through the following and in order of preference:

  1. http://www.iana.org/assignments/media-types/media-types.xhtml
  2. https://gitlab.freedesktop.org/xdg/shared-mime-info
  3. https://cdn.rawgit.com/jshttp/mime-db/master/db.json
  4. http://www.file-extensions.org/
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 is compatible. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 is compatible.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.1

    • No dependencies.
  • .NETFramework 4.8

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.7 520 9/19/2024
1.1.5 12,406 11/9/2023
1.1.4 6,341 9/22/2022
1.1.3 825 9/2/2022
1.1.1 12,913 4/11/2020
1.1.0 5,954 10/21/2018
1.0.3 2,770 9/20/2016
1.0.2 1,875 9/20/2016