Granting Permissions
file.grant_read_access(user)
Grants read-only access to a user. The user can view the file contents but cannot modify or delete it.
Parameters
| Name |
Type |
Description |
| user |
str |
Email address of the user, or "*" to grant public access |
Returns
| None |
This method modifies permissions in-place |
Example
# Grant read access to a specific user
file.grant_read_access("bob@company.com")
# Make file publicly readable
file.grant_read_access("*")
file.grant_create_access(user)
Grants create access to a user. Includes read permission plus the ability to create new files in folders.
For files, this is equivalent to read access.
Parameters
| Name |
Type |
Description |
| user |
str |
Email address of the user |
Returns
| None |
This method modifies permissions in-place |
Example
# Allow user to create files in a folder
folder.grant_create_access("alice@company.com")
file.grant_write_access(user)
Grants write access to a user. Includes read and create permissions plus the ability to modify existing files.
Parameters
| Name |
Type |
Description |
| user |
str |
Email address of the user |
Returns
| None |
This method modifies permissions in-place |
Example
# Allow user to edit files
file.grant_write_access("team@company.com")
file.grant_admin_access(user)
Grants admin access to a user. Includes all permissions plus the ability to manage permissions for other users.
Parameters
| Name |
Type |
Description |
| user |
str |
Email address of the user |
Returns
| None |
This method modifies permissions in-place |
Example
# Grant full control to admin
file.grant_admin_access("admin@company.com")
Checking Permissions
file.has_read_access(user)
Checks if a user has read access to the file or folder.
Parameters
| Name |
Type |
Description |
| user |
str |
Email address of the user to check |
Returns
| bool |
True if the user has read access, False otherwise |
Example
if file.has_read_access("bob@company.com"):
print("Bob can read this file")
file.has_create_access(user)
Checks if a user has create access. For folders, this means they can create new files.
Parameters
| Name |
Type |
Description |
| user |
str |
Email address of the user to check |
Returns
| bool |
True if the user has create access, False otherwise |
file.has_write_access(user)
Checks if a user has write access to modify the file.
Parameters
| Name |
Type |
Description |
| user |
str |
Email address of the user to check |
Returns
| bool |
True if the user has write access, False otherwise |
file.has_admin_access(user)
Checks if a user has admin access to manage permissions.
Parameters
| Name |
Type |
Description |
| user |
str |
Email address of the user to check |
Returns
| bool |
True if the user has admin access, False otherwise |
Revoking Permissions
file.revoke_read_access(user)
Revokes read access from a user. This removes all permissions for the user.
Parameters
| Name |
Type |
Description |
| user |
str |
Email address of the user, or "*" to revoke public access |
Returns
| None |
This method modifies permissions in-place |
file.revoke_create_access(user)
Revokes create access from a user. The user retains read access if they had higher permissions.
Parameters
| Name |
Type |
Description |
| user |
str |
Email address of the user |
Returns
| None |
This method modifies permissions in-place |
file.revoke_write_access(user)
Revokes write access from a user. The user retains read and create access if they had higher permissions.
Parameters
| Name |
Type |
Description |
| user |
str |
Email address of the user |
Returns
| None |
This method modifies permissions in-place |
file.revoke_admin_access(user)
Revokes admin access from a user. The user retains read, create, and write access.
Parameters
| Name |
Type |
Description |
| user |
str |
Email address of the user |
Returns
| None |
This method modifies permissions in-place |
Files API
syft_perm.files
Global instance providing access to file browsing functionality (files only).
In Jupyter notebooks, displays an interactive file browser widget showing only files.
Example
# Display interactive file browser (files only)
syft_perm.files
syft_perm.folders
Global instance providing access to folder browsing functionality (folders only).
In Jupyter notebooks, displays an interactive file browser widget showing only folders.
Example
# Display interactive file browser (folders only)
syft_perm.folders
syft_perm.files_and_folders
Global instance providing access to file and folder browsing functionality.
In Jupyter notebooks, displays an interactive file browser widget showing both files and folders.
This is the original behavior of the old .files API.
Example
# Display interactive file browser (both files and folders)
syft_perm.files_and_folders
syft_perm.files.all()
Returns all files (not folders) with permissions in your SyftBox datasites directory.
Returns
| list[dict] |
List of file metadata dictionaries containing name, path, permissions, size, etc. |
syft_perm.files.get(limit=50, offset=0)
Returns a paginated list of files with permissions.
Parameters
| Name |
Type |
Description |
| limit |
int |
Number of items per page (default: 50) |
| offset |
int |
Starting index (default: 0) |
Returns
| dict |
Dictionary with 'files', 'total_count', 'offset', 'limit', and 'has_more' keys |
syft_perm.files.search(query=None, admin=None, filetype=None)
Search files by query string and/or filter by admin user and file type.
Parameters
| Name |
Type |
Description |
| query |
str | None |
Search term for file names and paths |
| admin |
str | None |
Filter by admin email address |
| filetype |
str | None |
Filter by type: 'file' or 'folder' |
Returns
| Files |
Filtered Files instance (displays as widget in Jupyter) |
syft_perm.files[start:end]
Slice notation for selecting files by index range.
Parameters
| Name |
Type |
Description |
| start |
int |
Starting index (inclusive) |
| end |
int |
Ending index (exclusive) |
Returns
| Files |
Files instance with selected range |
Example
# Get first 10 files
first_ten = syft_perm.files[0:10]