File Browser¶
Table of Contents
Obtaining Access to the Gateway’s File System¶
filer = Gateway('vGateway-0dbc')
filer.login('USERNAME', 'PASSWORD')
file_browser = filer.files # the field is an instance of FileBrowser class object
List¶
- static FileBrowser.ls(_path)
Download¶
- FileBrowser.download(path, destination=None)
Download a file
- Parameters
path (str) – The file path on the Edge Filer
destination (str,optional) – File destination, if it is a directory, the original filename will be kept, defaults to the default directory
file_browser.download('cloud/users/Service Account/My Files/Documents/Sample.docx')
Create Directory¶
- FileBrowser.mkdir(path, recurse=False)
Create a new directory
- Parameters
path (str) – The path of the new directory
recurse (bool,optional) – Create subdirectories if missing, defaults to False
file_browser.mkdir('cloud/users/Service Account/My Files/Documents')
file_browser.mkdir('cloud/users/Service Account/My Files/The/quick/brown/fox', recurse = True)
Copy¶
- FileBrowser.copy(src, dest, overwrite=False)
Copy a file or a folder
- Parameters
src (str) – Source file or folder path
dest (str) – Destination folder path
overwrite (bool,optional) – Overwrite on conflict, defaults to False
"""
Copy the 'Documents' folder from Bruce Wayne to Alice Wonderland
The full path of the documents folder after the copy: 'cloud/users/Alice Wonderland/My Files/Documents'
"""
file_browser.copy('cloud/users/Bruce Wayne/My Files/Documents', 'cloud/users/Alice Wonderland/My Files')
"""Copy the file Summary.xlsx to another directory, and overwrite on conflict"""
file_browser.copy('cloud/users/Bruce Wayne/My Files/Summary.xlsx', 'cloud/users/Bruce Wayne/Spreadsheets', True)
Move¶
- FileBrowser.move(src, dest, overwrite=False)
Move a file or a folder
- Parameters
src (str) – Source file or folder path
dest (str) – Destination folder path
overwrite (bool,optional) – Overwrite on conflict, defaults to False
"""
Move the 'Documents' folder from Bruce Wayne to Alice Wonderland
The full path of the documents folder after the move: 'cloud/users/Alice Wonderland/My Files/Documents'
"""
file_browser.move('cloud/users/Bruce Wayne/My Files/Documents', 'cloud/users/Alice Wonderland/My Files')
"""Move the file Summary.xlsx to another directory, and overwrite on conflict"""
file_browser.move('cloud/users/Bruce Wayne/My Files/Summary.xlsx', 'cloud/users/Bruce Wayne/Spreadsheets', True)
Delete¶
- FileBrowser.delete(path)
Delete a file
- Parameters
path (str) – The file’s path on the gateway
file_browser.delete('cloud/users/Service Account/My Files/Documents')