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:
16
api/mime.py
16
api/mime.py
@@ -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
|
||||
|
Reference in New Issue
Block a user