diff --git a/Codout.Framework.Common/Codout.Framework.Common.csproj b/Codout.Framework.Common/Codout.Framework.Common.csproj
index 607fd00..bbe221d 100644
--- a/Codout.Framework.Common/Codout.Framework.Common.csproj
+++ b/Codout.Framework.Common/Codout.Framework.Common.csproj
@@ -22,6 +22,7 @@
+
diff --git a/Codout.Framework.Common/Extensions/IO.cs b/Codout.Framework.Common/Extensions/IO.cs
index 6b2bef8..5563b10 100644
--- a/Codout.Framework.Common/Extensions/IO.cs
+++ b/Codout.Framework.Common/Extensions/IO.cs
@@ -1,4 +1,5 @@
-using System.IO;
+using HeyRed.Mime;
+using System.IO;
using System.Net;
namespace Codout.Framework.Common.Extensions
@@ -73,7 +74,7 @@ public static string ReadWebPage(string url)
var request = WebRequest.Create(url);
// ReSharper disable PossibleNullReferenceException
using (Stream stream = request.GetResponse().GetResponseStream())
- // ReSharper restore PossibleNullReferenceException
+ // ReSharper restore PossibleNullReferenceException
{
if (stream != null)
{
@@ -550,6 +551,19 @@ public static string MimeType(this string strFileName)
}
return retval;
}
+
+ public static string GetMimeType(this string fileName)
+ {
+ if (string.IsNullOrWhiteSpace(fileName) || !Path.HasExtension(fileName))
+ return null;
+
+ switch (Path.GetExtension(fileName).ToLower())
+ {
+ case ".ogg": return "video/ogg";
+ }
+
+ return MimeTypesMap.GetMimeType(fileName);
+ }
#endregion
}
}
diff --git a/Codout.Framework.sln b/Codout.Framework.sln
index 5eac654..01cc411 100644
--- a/Codout.Framework.sln
+++ b/Codout.Framework.sln
@@ -1,4 +1,3 @@
-
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29806.167
@@ -29,6 +28,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Codout.Multitenancy", "Codo
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Codout.Mailer.AWS", "Codout.Mailer.AWS\Codout.Mailer.AWS.csproj", "{A51B2EDB-B261-41B2-B86F-BBA84AE46288}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Codout.Framework.Common.Test", "tests\Codout.Framework.Common.Test\Codout.Framework.Common.Test.csproj", "{6BDCEA2D-905D-4D64-AEB2-ECDFFA1D1451}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{4AB797AD-1525-46E7-B738-6B2400602CA4}"
+EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "API", "API", "{2834E4EA-7AD3-4D09-B62D-430CA4C2289B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DAL", "DAL", "{DA5D055F-6C44-466A-BE23-82DF4395EF36}"
@@ -97,6 +100,10 @@ Global
{A51B2EDB-B261-41B2-B86F-BBA84AE46288}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A51B2EDB-B261-41B2-B86F-BBA84AE46288}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A51B2EDB-B261-41B2-B86F-BBA84AE46288}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6BDCEA2D-905D-4D64-AEB2-ECDFFA1D1451}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6BDCEA2D-905D-4D64-AEB2-ECDFFA1D1451}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6BDCEA2D-905D-4D64-AEB2-ECDFFA1D1451}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6BDCEA2D-905D-4D64-AEB2-ECDFFA1D1451}.Release|Any CPU.Build.0 = Release|Any CPU
{DE657A9A-7AEE-4592-B199-EE0FAE47414D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DE657A9A-7AEE-4592-B199-EE0FAE47414D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DE657A9A-7AEE-4592-B199-EE0FAE47414D}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -106,6 +113,7 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
+ {6BDCEA2D-905D-4D64-AEB2-ECDFFA1D1451} = {4AB797AD-1525-46E7-B738-6B2400602CA4}
{281F92E8-F224-4036-858E-F04203D9107B} = {B6832CA4-604B-4DC8-908B-06405133B6B6}
{C1B0EF6F-49FD-4199-8BA3-7FD7BA3DD4BA} = {B6832CA4-604B-4DC8-908B-06405133B6B6}
{9F190AFF-FADE-4E54-96D8-FFD6F14ECBEA} = {2834E4EA-7AD3-4D09-B62D-430CA4C2289B}
diff --git a/tests/Codout.Framework.Common.Test/Codout.Framework.Common.Test.csproj b/tests/Codout.Framework.Common.Test/Codout.Framework.Common.Test.csproj
new file mode 100644
index 0000000..65ae88b
--- /dev/null
+++ b/tests/Codout.Framework.Common.Test/Codout.Framework.Common.Test.csproj
@@ -0,0 +1,20 @@
+
+
+
+ net5.0
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/Codout.Framework.Common.Test/Extensions/IOTest.cs b/tests/Codout.Framework.Common.Test/Extensions/IOTest.cs
new file mode 100644
index 0000000..7fcf436
--- /dev/null
+++ b/tests/Codout.Framework.Common.Test/Extensions/IOTest.cs
@@ -0,0 +1,22 @@
+using Codout.Framework.Common.Extensions;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Codout.Framework.Common.Test.Extensions
+{
+ [TestClass]
+ public class IOTest
+ {
+ [TestMethod]
+ [DataRow(".JPG", "image/jpeg")]
+ [DataRow(".ogg", "video/ogg")]
+ [DataRow(".webm", "video/webm")]
+ [DataRow(null, null)]
+ [DataRow("", null)]
+ [DataRow("noFileExtension", null)]
+ [DataRow(".invalidExtension", "application/octet-stream")]
+ public void GetMimeTypeTest(string fileName, string expectedMimeType)
+ {
+ Assert.AreEqual(expectedMimeType, IO.GetMimeType(fileName));
+ }
+ }
+}
\ No newline at end of file