def on_get(self, req, resp, fid):
''' Return a JSON representation of the directory tree. The JSON response has the
following attributes:
- ``type``: file or folder
- ``name``: The base name of the file/folder
- ``path``: Absolute path to the object.
- ``id``: URL-safe base64 encoding of the ``path``
- ``children``: Only present if ``type`` is ``folder``. A list of all
children of this folder, each having the same representation.
Args:
fid (str): the base64 encoded url safe ID for the path to the root folder
Example::
http localhost:8000/files/tree/{fid}
'''
try:
self._data_store.validate_fid(fid)
resp.status = falcon.HTTP_OK
path = serializers.path_from_id(fid)
resp.body = json.dumps(serializers.directory_tree_serializer(path))
except PermissionError as error:
resp.status = falcon.HTTP_BAD_REQUEST
resp.body = str(error)
评论列表
文章目录