#93: Making some changes to how the file extension is determined

This commit is contained in:
kdeng00
2024-07-18 15:26:59 -04:00
parent 470b7a953a
commit 45c2bd9572
5 changed files with 49 additions and 13 deletions
@@ -100,6 +100,7 @@ public class MetadataRetriever
}
var fileType = FileTypeChecker.FileTypeValidator.GetFileType(fileStream);
Console.WriteLine($"Filetype: {fileType}");
Console.WriteLine($"Extension: {fileType.Extension}");
@@ -108,6 +109,20 @@ public class MetadataRetriever
}
}
public string FileExtensionType(string path)
{
var extensionRaw = System.IO.Path.GetExtension(path);
if (extensionRaw[0] == '.')
{
return extensionRaw.Substring(1);
}
else
{
return extensionRaw;
}
}
public bool IsSupportedFile(IFormFile file)
{
var supportedTypes = this._supportedAudioFileTypes;
@@ -124,6 +139,22 @@ public class MetadataRetriever
return supportedTypes.Contains(extensionType);
}
public bool IsSupportedFile(string path)
{
var supportedTypes = this._supportedAudioFileTypes;
this._supportedImageFileTypes.ForEach(t =>
{
if (!supportedTypes.Contains(t))
{
supportedTypes.Add(t);
}
});
var extensionType = this.FileExtensionType(path).ToLower();
return supportedTypes.Contains(extensionType);
}
public Song RetrieveMetaData(string filePath)
{
Song song = new Song();