-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1a69e86
commit fbbe34a
Showing
4 changed files
with
1,262 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// The Sisk Framework source code | ||
// Copyright (c) 2023 PROJECT PRINCIPIUM | ||
// | ||
// The code below is licensed under the MIT license as | ||
// of the date of its publication, available at | ||
// | ||
// File name: MimeHelper.cs | ||
// Repository: https://github.com/sisk-http/core | ||
|
||
using Sisk.Core.Internal; | ||
|
||
namespace Sisk.Core.Http; | ||
|
||
/// <summary> | ||
/// Provides useful helper methods for resolving mime-types from common formats. | ||
/// </summary> | ||
public static class MimeHelper | ||
{ | ||
/// <summary> | ||
/// Gets the content mime-type from the specified file extension. | ||
/// </summary> | ||
/// <param name="fileExtension">The file extension, with or without the initial dot.</param> | ||
/// <param name="defaultMime">The default mime-type when the file is not found.</param> | ||
/// <returns>The best matched mime-type, or the default if no mime-type was matched with the specified extension.</returns> | ||
public static string GetMimeType(string fileExtension, string defaultMime = "application/octet-stream") | ||
{ | ||
return MimeTypeList.ResolveMimeType(fileExtension.TrimStart('.').ToLower()) ?? defaultMime; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.