merge upstream

get_content_type_no_sub
media plugin forces type to upload
This commit is contained in:
2015-04-26 21:19:31 +02:00
parent fe78a49367
commit fa55b0b14a
2 changed files with 70 additions and 34 deletions

View File

@ -3,6 +3,7 @@ do
local mimetype = {}
-- TODO: Add more?
local types = {
["text/html"] = "html",
["text/css"] = "css",
@ -31,6 +32,7 @@ local types = {
["application/pdf"] = "pdf",
["application/postscript"] = "ps",
["application/rtf"] = "rtf",
["application/vnd.android.package-archive"] = "apk",
["application/vnd.ms-excel"] = "xls",
["application/vnd.ms-powerpoint"] = "ppt",
["application/vnd.wap.wmlc"] = "wmlc",
@ -72,10 +74,12 @@ local types = {
["video/x-msvideo"] = "avi"
}
-- Returns the common file extension from a content-type
function mimetype.get_mime_extension(content_type)
return types[content_type]
end
-- Returns the mimetype and subtype
function mimetype.get_content_type(extension)
for k,v in pairs(types) do
if v == extension then
@ -84,5 +88,15 @@ function mimetype.get_content_type(extension)
end
end
-- Returns the mimetype without the subtype
function mimetype.get_content_type_no_sub(extension)
for k,v in pairs(types) do
if v == extension then
-- Before /
return k:match('([%w-]+)/')
end
end
end
return mimetype
end