Closed mzur closed 2 years ago
Yes - you can filter the files by a ?parent=
. Or, depending on your needs, use get_all_media_files_in_subtree
Or if you need both bundles and folders from a parent folder, use get_media_file_contents
Thanks! What if I want to get the items in the root directory (see example above)? An empty ?parent=
has no effect and both methods you linked require a parent file/id. I also found get_all_media_files_for_media_root
but this again requires a root (directory?).
Edit: I now used api/2/media/roots
to get the root paths (I think they are, anyway). However, this seems to list all paths, even the ones I don't have access to. Can/should these be filtered out?
Edit2: Is the root directory always called .projects
or can it be anything?
@mzur the volume root is a directory itself, which you can pass as a ?parent=
- you can look it up as a file with an empty path
- e.g. /api/2/media/files?path=&volume_id=123
and then request its /contents
.
The root
in get_all_media_files_for_media_root
refers to a MediaRoot
- it's getting a flat list of all files under a given MediaRoot.
For a list of paths you're allowed to access, you can check out the allowed_fs_paths
field of your own profile at /api/2/users/me
.
.projects
is the default container directory for Workspaces, but Media Libraries are not confined to it and can reside outside (even in the volume root itself). Workspaces can be moved by the user to outside of .projects
too.
Thanks again for the clarification. Unfortunately, /api/2/media/files?path=&volume_id=1
did not return anything (I got the ID from /api/2/volumes
). There is also no allowed_fs_paths
in what's returned by /api/2/users/me
.
I now took a different approach with /api/2/media/root-permissions/mine/resolved
which seems to list only the paths that the current user has access to. I only need to strip the volume path prefix to get a list that looks like what I expected. Is anything wrong with this approach?
Sorry - it was volume=
instead of volume_id=
.
Also for paths, they're indeed not included in the user profile, but are included in the full user account (e.g. /api/2/users/95?include_allowed_fs_paths=true
).
But your approach with querying permissions is perfectly fine too :+1: - the only difference is that it won't return the non-media-library paths ("ancillary filesystem access path" in older versions or "additional filesystem permissions" in newer ones) .
Hi, I have another question regarding the Elements API, this time about the
api/2/media/files
endpoint. Is there a way to filter the returned items by the directory structure, i.e. return only the top-level items in a directory?For example, given the following files and directories:
If I perform a query to
api/2/media/files
, e.g. with an imaginaryseparate_directories=true
parameter, then I get only the items: