File Browser

List

FileBrowser.ls(path)

Execute ls on the provided path

Parameters:path (str) – Path to execute ls on
file_browser.ls('')

file_browser.ls('My Files')
FileBrowser.walk(path)

Perform walk on the provided path

Parameters:path (str) – Path to perform walk on
file_browser.walk('My Files')

Download

FileBrowser.download(path, destination=None)

Download a file

Parameters:
  • path (str) – Path of the file to download
  • destination (str,optional) – File destination, if it is a directory, the original filename will be kept, defaults to the default directory
file_browser.download('My Files/Documents/Sample.docx')

Create Directory

FileBrowser.mkdir(path, recurse=False)

Create a new directory

Parameters:
  • path (str) – Path of the directory to create
  • recurse (bool,optional) – Whether to create the path recursivly, defaults to False
file_browser.mkdir('My Files/Documents')

file_browser.mkdir('The/quick/brown/fox', recurse = True)

Rename

FileBrowser.rename(path, name)

Rename a file

Parameters:
  • path (str) – Path of the file or directory to rename
  • name (str) – The name to rename to
file_browser.rename('My Files/Documents/Sample.docx', 'Wizard Of Oz.docx')

Delete

FileBrowser.delete(path)

Delete a file

Parameters:path (str) – Path of the file or directory to delete
file_browser.delete('My Files/Documents/Sample.docx')
FileBrowser.delete_multi(*args)

Delete multiple files and/or directories

Parameters:*args – Variable lengthed list of paths of files and/or directories to delete
file_browser.delete_multi('My Files/Documents/Sample.docx', 'The/quick/brown/fox')

Recover

FileBrowser.undelete(path)

Restore a previously deleted file or directory

Parameters:path (str) – Path of the file or directory to restore
file_browser.undelete('My Files/Documents/Sample.docx')
FileBrowser.undelete_multi(*args)

Restore previously deleted multiple files and/or directories

Parameters:*args – Variable length list of paths of files and/or directories to restore
file_browser.undelete_multi('My Files/Documents/Sample.docx', 'The/quick/brown/fox')

Copy

FileBrowser.copy(src, dest)

Copy a file or directory

Parameters:
  • src (str) – The source path of the file or directory
  • dst (str) – The destination path of the file or directory
file_browser.copy('My Files/Documents/Sample.docx', 'The/quick/brown/fox')
FileBrowser.copy_multi(src, dest)
file_browser.copy_multi(['My Files/Documents/Sample.docx', 'My Files/Documents/Burndown.xlsx'], 'The/quick/brown/fox')

Move

FileBrowser.move(src, dest)

Move a file or directory

Parameters:
  • src (str) – The source path of the file or directory
  • dst (str) – The destination path of the file or directory
file_browser.move('My Files/Documents/Sample.docx', 'The/quick/brown/fox')
FileBrowser.move_multi(src, dest)
file_browser.move_multi(['My Files/Documents/Sample.docx', 'My Files/Documents/Burndown.xlsx'], 'The/quick/brown/fox')

Collaboration Shares

FileBrowser.share(path, recipients, as_project=True, allow_reshare=True, allow_sync=True)

Share a file or a folder

Parameters:
  • path (str) – The path of the file or folder to share
  • recipients (list[cterasdk.core.types.ShareRecipient]) – A list of share recipients
  • as_project (bool,optional) – Share as a team project, defaults to True when the item is a cloud folder else False
  • allow_reshare (bool,optional) – Allow recipients to re-share this item, defaults to True
  • allow_sync (bool,optional) – Allow recipients to sync this item, defaults to True when the item is a cloud folder else False
Returns:

A list of all recipients added to the collaboration share

Return type:

list[cterasdk.core.types.ShareRecipient]

"""
Share with a local user and a local group.
- Grant the local user with read only access for 30 days
- Grant the local group with read write access with no expiration
"""

alice = portal_types.UserAccount('alice')
engineers = portal_types.GroupAccount('Engineers')

recipients = []

alice_rcpt = portal_types.ShareRecipient.local_user(alice).expire_in(30).read_only()
engineers_rcpt = portal_types.ShareRecipient.local_group(engineering).read_write()

file_browser.share('Codebase', [alice_rcpt, engineers_rcpt])
"""
Share with an external recipient
- Grant the external user with preview only access for 10 days
"""
jsmith = portal_types.ShareRecipient.external('jsmith@hotmail.com').expire_in(10).preview_only())
file_browser.share('My Files/Projects/2020/ProjectX', [jsmith])

"""
Share with an external recipient, and require 2 factor authentication
- Grant the external user with read only access for 5 days, and require 2 factor authentication over e-mail
"""
jsmith = portal_types.ShareRecipient.external('jsmith@hotmail.com', True).expire_in(5).read_only())
file_browser.share('My Files/Projects/2020/ProjectX', [jsmith])
"""
Share with a domain groups
- Grant the Albany domain group with read write access with no expiration
- Grant the Cleveland domain group with read only access with no expiration
"""
albany_group = portal_types.GroupAccount('Albany', 'ctera.com')
cleveland_group = portal_types.GroupAccount('Cleveland', 'ctera.com')

albany_rcpt = portal_types.ShareRecipient.domain_group(albany_group).read_write()
cleveland_rcpt = portal_types.ShareRecipient.domain_group(cleveland_group).read_only()

file_browser.share('Cloud/Albany', [albany_rcpt, cleveland_rcpt])
FileBrowser.add_share_recipients(path, recipients)

Add share recipients

Parameters:
Returns:

A list of all recipients added

Return type:

list[cterasdk.core.types.ShareRecipient]

Note

if the share recipients provided as an argument already exist, they will be skipped and not updated

FileBrowser.remove_share_recipients(path, accounts)

Remove share recipients

Parameters:
Returns:

A list of all share recipients removed

Return type:

list[cterasdk.core.types.PortalAccount]

FileBrowser.unshare(path)

Unshare a file or a folder

"""
Unshare a file or a folder
"""
file_browser.unshare('Codebase')
file_browser.unshare('My Files/Projects/2020/ProjectX')
file_browser.unshare('Cloud/Albany')