prefix Property
A prefix used to restrict the results returned when listing files.
Syntax
def get_prefix() -> str: ... def set_prefix(value: str) -> None: ...
prefix = property(get_prefix, set_prefix)
Default Value
""
Remarks
This property, if non-empty, is used to restrict the values returned by list_files, list_file_versions, or list_multipart_uploads to only the items whose names begin with the given prefix.
Note: If the currently-authenticated application key is restricted to a specific file name prefix (indicated by the account_allowed_prefix property being non-empty), then this property will automatically be set to that prefix if it is empty when one of the aforementioned methods is called.
File Hierarchy Traversal
By using the delimiter and prefix properties in tandem, applications can effectively "traverse" a virtual hierarchy of files (or file versions) as if it were a filesystem. For example, assume that files with the following names exist within a bucket:
- MyCompany
- MyCompany/Department1
- MyCompany/Department2
- MyCompany/Department2/EmployeeA
- MyCompany/Department2/EmployeeB
With delimiter set to /, we can set prefix to successively "deeper" values before calling list_files or list_file_versions for the following effect:
prefix Value | Files Returned | Folders Returned |
(empty) | MyCompany | MyCompany/ |
MyCompany/ | MyCompany/Department1 MyCompany/Department2 | MyCompany/Department2/ |
MyCompany/Department2/ | MyCompany/Department2/EmployeeA MyCompany/Department2/EmployeeB | (none) |