{"id":24042418,"url":"https://github.com/litenova/dmime","last_synced_at":"2025-08-13T21:40:28.243Z","repository":{"id":123400903,"uuid":"373644338","full_name":"litenova/DMime","owner":"litenova","description":"Detects a given file's MIME type based on file content regardless of file extension","archived":false,"fork":false,"pushed_at":"2023-07-07T06:30:35.000Z","size":15404,"stargazers_count":3,"open_issues_count":6,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-01T01:42:57.888Z","etag":null,"topics":["csharp","detector","mime-type"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/litenova.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-06-03T21:21:45.000Z","updated_at":"2023-03-07T12:19:48.000Z","dependencies_parsed_at":"2023-07-10T08:00:26.403Z","dependency_job_id":null,"html_url":"https://github.com/litenova/DMime","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/litenova/DMime","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litenova%2FDMime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litenova%2FDMime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litenova%2FDMime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litenova%2FDMime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/litenova","download_url":"https://codeload.github.com/litenova/DMime/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litenova%2FDMime/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270322687,"owners_count":24564643,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-13T02:00:09.904Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","detector","mime-type"],"created_at":"2025-01-08T22:54:57.271Z","updated_at":"2025-08-13T21:40:28.232Z","avatar_url":"https://github.com/litenova.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dmime\n[![CI/CD](https://github.com/litenova/DMime/actions/workflows/publish-packages.yml/badge.svg)](https://github.com/litenova/DMime/actions/workflows/publish-packages.yml)\n[![NuGet](https://img.shields.io/nuget/vpre/Dmime.svg)](https://www.nuget.org/packages/Dmime)\n[![Coverage Status](https://coveralls.io/repos/github/litenova/DMime/badge.svg?branch=main)](https://coveralls.io/github/litenova/DMime?branch=main)\n\nA fast and efficient library to detect a given file's MIME type based on the file content regardless of file extension.\n\n* Written in .NET 7\n* No Dependencies\n* No Reflection\n* Easy to Use\n* Supported Types\n    * MP4\n    * BMP\n    * GIF\n    * JPEG\n    * PNG\n    * WEBP\n    * PDF\n    * MP3\n    * EMF\n    * TIFF\n    * ICO\n    * WMF\n\n## How to Use\n\n### Extension Method\n\nInstall the `DMime` package:\n\n```\ndotnet add package Dmime\n```\n\nThen use the `DetectMimeTypeAsync` or `DetectMimeType` extension methods on any `Stream` type.\n\n```c#\n    // an unkown file without extension\nFileStream stream = File.OpenRead(\"webp-sample-550w-404h\");\n\nvar result = await stream.DetectMimeTypeAsync(); // result = image/webp\n```\n\n### Dependency\n\nInstall the `Dmime.Extensions.MicrosoftDependencyInjection` package:\n\n```\ndotnet add package Dmime.Extensions.MicrosoftDependencyInjection\n```\n\nRegister the dependency into ASP.NET Core DI container:\n\n```c#\nservices.AddMimeDetector();\n```\n\nThen inject the `IMimeDetector` to your desired class and use the `DetectAsync` or `Detect` methods accordingly.\n\n```c#\n  [ApiController]\n  [Route(\"[controller]\")]\n  public class UploadController\n  {\n      private readonly IMimeDetector _mimeDetector;\n  \n      public UploadController(IMimeDetector mimeDetector)\n      {\n          _mimeDetector = mimeDetector;\n      }\n  \n      [HttpPost]\n      public async Task\u003cIActionResult\u003e SendNotification(IFormFile formFile)\n      {\n          var streamContent = formFile.OpenReadStream();\n                  \n          var result = await _mimeDetector.DetectMimeTypeAsync(streamContent);\n  \n          return Ok(result);\n      }\n  }\n```\n\n## Sponsor \n\nThanks to JetBrains for supporting open source projects by providing JetBrains Rider IDE for free.\n\n[![alt text][image]][hyperlink]\n\n[hyperlink]: https://www.jetbrains.com/\n[image]: assets/jetbrains-variant-4.png\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flitenova%2Fdmime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flitenova%2Fdmime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flitenova%2Fdmime/lists"}