def save_zip(self, stream, content_type, name=None):
'''Save the zip stream to disk and extract its contents
'''
# Make sure the storage path exists
ensure_dir(self._storage_path)
ext = mimetypes.guess_extension(content_type)
if not name:
name = str(self._uuidgen())
fname = '{uuid}{ext}'.format(uuid=name, ext=ext)
archive_path = os.path.join(self._storage_path, fname)
self._write(archive_path, stream)
# extract the zip file
directory = extract_model(archive_path, name, self._storage_path)
return fmdb.id_from_path(directory), name
评论列表
文章目录