FilesClient
Methods
__init__()
download()
Download a file from Datagrok.
Parameters
| Name | Type | Description |
|---|---|---|
| connector | str or DataConnection | DataConnection or ID or Grok name. |
| path | str | Path to file in a connector |
Returns
| Type | Description |
|---|---|
| Union[pd.DataFrame, bytes] | If requested file is csv, returns corresponding pd.DataFrame. Otherwise returns bytes with file content. |
upload()
Uploads a file to Datagrok.
Parameters
| Name | Type | Description |
|---|---|---|
| connector | str or DataConnection | DataConnection or ID or Grok name. |
| path | str | Path to file in a connector |
| file_path | str | Path to local file that needs to be uploaded |
sync_dir()
Syncs the content of a local directory with a remote directory on a server, updating local files and metadata based on the response. This method compares the current state of the local directory with the remote directory and updates files based on their modified status or whether they have been deleted. It uses a provided connector to connect to a remote service and syncs the data, storing metadata about file versions and deletions in a .sync_meta.json file. If a file has been deleted on the server, it will also be deleted locally.
Parameters
| Name | Type | Description |
|---|---|---|
| connector | str or DataConnection | DataConnection or ID or Grok name. |
| remote_path | str | The path on the server connection to sync with. Should be directory |
| dir | str | The local directory to sync. If the directory doesn't exist, it will be created. |
| ext | str, optional | A file extension filter to limit the types of files to sync. If not specified, all files are synced. |
| recursive | bool | Whether to sync the directory recursively, including subdirectories. If False, only files in the root of the directory are synced. |
| sync_meta_file | str, optional | The name of the metadata file that stores the eTags and sync information for the files. This file is used to track the current state of the local directory and should be present for syncing to work correctly. |