Bugfix: mime now expects a filepath string
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "../logger.hpp"
|
||||
#include <filesystem>
|
||||
#include "mime.hpp"
|
||||
#include <unordered_map>
|
||||
|
||||
@@ -13,13 +14,7 @@ namespace Http
|
||||
multipart
|
||||
*/
|
||||
|
||||
std::string GetMimeType(std::filesystem::path const & path)
|
||||
{
|
||||
auto const extension = path.extension();
|
||||
return GetMimeType(extension.string());
|
||||
}
|
||||
|
||||
std::string GetMimeType(std::string const & extension)
|
||||
std::string GetMimeType(std::string const & filePath)
|
||||
{
|
||||
static std::unordered_map<std::string, FileType> fileExtensionMap
|
||||
{
|
||||
@@ -33,7 +28,8 @@ namespace Http
|
||||
{".mp3", FileType::MP3},
|
||||
{".mp4", FileType::MP4},
|
||||
};
|
||||
|
||||
|
||||
std::string const extension = std::filesystem::path(filePath).extension();
|
||||
auto const findResult = fileExtensionMap.find(extension);
|
||||
if (findResult == fileExtensionMap.end())
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#pragma once
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -17,7 +16,6 @@ namespace Http
|
||||
MP4
|
||||
};
|
||||
|
||||
std::string GetMimeType(std::filesystem::path const & path);
|
||||
std::string GetMimeType(std::string const & extension);
|
||||
std::string GetMimeType(std::string const & filePath);
|
||||
std::string GetMimeType(FileType const fileType);
|
||||
}
|
||||
Reference in New Issue
Block a user