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