def __init__(self, *args, **kwargs):
"""
Set name, ext and content_type (if possible) automatically initialize by path.
"""
super(File, self).__init__(*args, **kwargs)
pieces = os.path.splitext(os.path.basename(str(self.path)))
self.name, self.ext = pieces[0], pieces[1][1:]
self.content_type = mimetypes.guess_type(self.full_path)[0]
评论列表
文章目录