1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-17 07:41:26 +00:00

[api] handle the situation when mime type does not exist in the MIME_MAP

This commit is contained in:
poetwang
2012-09-01 17:33:17 +08:00
parent 37474248b5
commit 738c0e47e9

View File

@@ -414,18 +414,20 @@ zip application/zip
"""
MIME_MAP = {}
for line in mime_str.splitlines():
pair = line.split()
if len(pair) == 2:
MIME_MAP[pair[0]] = pair[1]
MIME_MAP[pair[0]] = pair[1]
def get_file_mime(name):
sufix = os.path.splitext(name)[1][1:]
if sufix:
return MIME_MAP[sufix]
return None
try:
sufix = os.path.splitext(name)[1][1:]
if sufix:
return MIME_MAP[sufix]
return None
except Exception, e:
return None
if __name__ == "__main__":
print MIME_MAP