Commit 43fde8b9 authored by Paweł Wegner's avatar Paweł Wegner
Browse files

Added Item::fromMimeType.

parent 12d3bee7
......@@ -55,4 +55,16 @@ IItem::FileType Item::type() const { return type_; }
void Item::set_type(FileType t) { type_ = t; }
IItem::FileType Item::fromMimeType(const std::string& mime_type) {
std::string type = mime_type.substr(0, mime_type.find_first_of('/'));
if (type == "audio")
return IItem::FileType::Audio;
else if (type == "video")
return IItem::FileType::Video;
else if (type == "image")
return IItem::FileType::Image;
else
return IItem::FileType::Unknown;
}
} // namespace cloudstorage
......@@ -50,6 +50,8 @@ class Item : public IItem {
FileType type() const;
void set_type(FileType);
static FileType fromMimeType(const std::string& mime_type);
private:
std::string filename_;
std::string id_;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment