cterasdk.edge.files.browser module#

class cterasdk.edge.files.browser.FileBrowser(edge)#

Bases: BaseCommand

Edge Filer File Browser API.

copy(path, destination=None, overwrite=False)#

Copy a file or directory.

Parameters:
  • path (str) – Source file or directory path.

  • destination (str) – Destination directory path.

  • overwrite (bool, optional) – Overwrite on conflict. Defaults to False.

Raises:

cterasdk.exceptions.io.edge.CopyError – Raised on error to copy a file or directory.

delete(path)#

Delete a file or directory.

Parameters:

path (str) – File or directory path.

Returns:

Deleted object path.

Return type:

str

Raises:

cterasdk.exceptions.io.edge.DeleteError – Raised on error to delete a file or directory.

download(path, destination=None)#

Download a file.

Parameters:
  • path (str) – The file path on the Edge Filer.

  • destination (str, optional) – File destination. If a directory is provided, the original filename is preserved. Defaults to the default download directory.

Returns:

Path to the local file.

Return type:

str

Raises:

cterasdk.exceptions.io.edge.OpenError – Raised on error to obtain a file handle.

download_many(target, objects, destination=None)#

Download selected files and/or directories as a ZIP archive.

Warning

The provided list of objects is not validated. Only existing files and directories will be included in the resulting ZIP file.

Parameters:
  • target (str) – Path to the cloud folder containing the files and directories to download.

  • objects (list[str]) – List of file and/or directory names to include in the download.

  • destination (str) – Optional. Path to the destination file or directory. If a directory is provided, the original filename is preserved. Defaults to the default download directory.

Returns:

Path to the local file.

Return type:

str

exists(path)#

Check whether an item exists.

Parameters:

path (str) – Path.

Returns:

True if the item exists, False otherwise.

Return type:

bool

handle(path)#

Get a file handle.

Parameters:

path (str) – Path to a file.

Returns:

File handle.

Return type:

object

Raises:

cterasdk.exceptions.io.edge.OpenError – Raised on error to obtain a file handle.

handle_many(directory, *objects)#

Get a ZIP archive file handle.

Parameters:
  • directory (str) – Path to a folder.

  • objects (args) – Files and folders to include.

Returns:

File handle.

Return type:

object

listdir(path=None)#

List directory contents.

Parameters:

path (str) – Path. Defaults to the root directory.

Returns:

Directory contents.

Return type:

list[cterasdk.cio.edge.types.EdgeResource]

Raises:
makedirs(path)#

Create a directory recursively.

Parameters:

path (str) – Directory path.

Returns:

Remote directory path.

Return type:

str

Raises:

cterasdk.exceptions.io.edge.CreateDirectoryError – Raised on error to create a directory.

mkdir(path)#

Create a new directory.

Parameters:

path (str) – Directory path.

Returns:

Remote directory path.

Return type:

str

Raises:

cterasdk.exceptions.io.edge.CreateDirectoryError – Raised on error to create a directory.

move(path, destination=None, overwrite=False)#

Move a file or directory.

Parameters:
  • path (str) – Source file or directory path.

  • destination (str) – Destination directory path.

  • overwrite (bool, optional) – Overwrite on conflict. Defaults to False.

Raises:

cterasdk.exceptions.io.edge.MoveError – Raised on error to move a file or directory.

properties(path)#

Get object properties.

Parameters:

path (str) – Path.

Returns:

Object properties.

Return type:

cterasdk.cio.edge.types.EdgeResource

Raises:

cterasdk.exceptions.io.core.GetMetadataError – Raised on error to obtain object metadata.

rename(path, new_name, overwrite=False)#

Rename a file or directory.

Parameters:
  • path (str) – Path of the file or directory to rename.

  • new_name (str) – New name for the file or directory.

  • overwrite (bool, optional) – Overwrite on conflict. Defaults to False.

Returns:

Remote object path.

Return type:

str

Raises:

cterasdk.exceptions.io.edge.RenameError – Raised on error to rename a file or directory.

upload(destination, handle, name=None)#

Upload from a file handle.

Parameters:
  • destination (str) – Remote path.

  • handle (object) – File-like handle.

  • name (str, optional) – Filename to use if it cannot be derived from destination

Returns:

Remote file path.

Return type:

str

Raises:

cterasdk.exceptions.io.edge.UploadError – Raised on upload failure.

upload_file(path, destination)#

Upload a file.

Parameters:
  • path (str) – Local path.

  • destination (str) – Remote path.

Returns:

Remote file path.

Return type:

str

Raises:

cterasdk.exceptions.io.edge.UploadError – Raised on upload failure.

walk(path=None)#

Walk directory contents.

Parameters:

path (str, optional) – Path to walk. Defaults to the root directory.

Returns:

A generator of file-system objects.

Return type:

Iterator[cterasdk.cio.edge.types.EdgeResource]

Raises: