Remote operations
SSRF guard for outbound HTTP requests.
validate_http_url rejects non-http(s) schemes, resolves the host, and
rejects private / loopback / link-local / reserved IP ranges. Every remote
function that accepts a user-supplied URL must pass it through here first.
- automation_file.remote.url_validator.validate_http_url(url, *, allow_private=False)[source]
Return
urlif safe; raiseUrlValidationExceptionotherwise.allow_private=Truerelaxes the private/loopback/link-local checks for callers that need to reach LAN services (e.g. on-prem WebDAV). Scheme and host checks still apply. Callers must opt in explicitly — the default remains strict SSRF blocking.
SSRF-guarded HTTP downloader.
- automation_file.remote.http_download.download_file(file_url, file_name, chunk_size=65536, timeout=15, max_bytes=20971520, progress_name=None, resume=False, expected_sha256=None)[source]
Download
file_urltofile_namewith progress display.Validates the URL against SSRF rules, disables redirects, enforces a size cap, retries transient network errors up to three times, and uses default TLS verification.
Pass
progress_nameto register the transfer withprogress_registryso it can be polled or cancelled from the GUI. Whenresume=Truethe download streams into<file_name>.partand, if that file already exists from a previous interrupted run, sendsRange: bytes=<existing>-to continue where it stopped (append mode); the.partfile is atomically renamed tofile_nameon success. Passexpected_sha256to verify the finished file; a mismatch is logged, the download is removed, and the function returnsFalse. Returns True on success.
Google Drive
Google Drive client (Singleton Facade).
Wraps OAuth2 credential loading and exposes a lazily-built service attribute
that every operation module calls through.
- class automation_file.remote.google_drive.client.GoogleDriveClient(scopes=('https://www.googleapis.com/auth/drive',))[source]
Bases:
objectHolds credentials and the Drive API service handle.
Delete-side Google Drive operations.
- automation_file.remote.google_drive.delete_ops.drive_delete_file(file_id)[source]
Delete a file by Drive ID. Returns the API response or None.
Folder (mkdir-equivalent) operations on Google Drive.
- automation_file.remote.google_drive.folder_ops.drive_add_folder(folder_name)[source]
Create a folder on Drive. Returns the new folder’s ID or None.
Search-side Google Drive operations.
- automation_file.remote.google_drive.search_ops.drive_search_all_file()[source]
Return
{name: id}for every file visible to the current token.
- automation_file.remote.google_drive.search_ops.drive_search_field(field_pattern)[source]
Return
{name: id}for a list call with a customfields=pattern.
- automation_file.remote.google_drive.search_ops.drive_search_file_mimetype(mime_type)[source]
Return
{name: id}for files matchingmime_type(all pages).
Upload-side Google Drive operations.
- automation_file.remote.google_drive.upload_ops.drive_upload_dir_to_drive(dir_path)[source]
Upload every file in
dir_path(non-recursive) to the Drive root.
- automation_file.remote.google_drive.upload_ops.drive_upload_dir_to_folder(folder_id, dir_path)[source]
Upload every file in
dir_path(non-recursive) to a Drive folder.
- automation_file.remote.google_drive.upload_ops.drive_upload_to_drive(file_path, file_name=None)[source]
Upload a single file to the Drive root.
- automation_file.remote.google_drive.upload_ops.drive_upload_to_folder(folder_id, file_path, file_name=None)[source]
Upload a single file into a specific Drive folder.
Download-side Google Drive operations.
- automation_file.remote.google_drive.download_ops.drive_download_file(file_id, file_name)[source]
Download a single file by ID to
file_nameon disk.Returns the in-memory buffer on success, or
Noneon failure. The file is only written after the download completes cleanly, so a failed request cannot leave an empty file behind.
S3
Bundled with automation_file; registered automatically by
automation_file.core.action_registry.build_default_registry().
S3 delete operations.
Azure Blob
Bundled with automation_file; registered automatically by
automation_file.core.action_registry.build_default_registry().
Azure Blob delete operations.
Dropbox
Bundled with automation_file; registered automatically by
automation_file.core.action_registry.build_default_registry().
Dropbox delete operations.
SFTP
Bundled with automation_file; registered automatically by
automation_file.core.action_registry.build_default_registry(). Uses
paramiko.RejectPolicy — unknown hosts are never auto-added.
SFTP delete operations.
FTP / FTPS
Bundled with automation_file; registered automatically by
automation_file.core.action_registry.build_default_registry().
Supports plain FTP and explicit FTPS (via FTP_TLS + auth()).
FTP delete operations.
WebDAV
HTTP-based remote storage client. Uses PROPFIND for directory listings and
rejects private/loopback targets unless allow_private_hosts=True.
SMB / CIFS
Built on the high-level smbclient API from smbprotocol. Uses UNC
paths (\\\\server\\share\\path) under the hood and defaults to
encrypted sessions.
SMB / CIFS client built on smbprotocol’s high-level smbclient API.
Scope mirrors automation_file.remote.webdav.client — existence check,
upload, download, delete, directory create, and shallow listing. The
underlying session is registered per (server, username) pair and torn
down when SMBClient.close() runs. smbprotocol is imported lazily so
importing this module never touches the optional dependency.
- class automation_file.remote.smb.client.SMBClient(server, share, username=None, password=None, *, port=445, encrypt=True, connection_timeout=30.0)[source]
Bases:
objectMinimal SMB client scoped to the operations used by this project.
- Parameters:
- delete(remote_path)[source]
Remove the remote file at
remote_path.- Parameters:
remote_path (str)
- Return type:
None
- mkdir(remote_path)[source]
Create the remote directory at
remote_path(parents must exist).- Parameters:
remote_path (str)
- Return type:
None
fsspec bridge
Thin wrapper over fsspec so any filesystem it knows about (memory, local, s3, gcs, abfs, …) can be driven through the action registry. No SSRF guard — treat as a developer helper, not a remote-ingestion surface.
Bridge helpers that expose fsspec backends through the same verbs as our native clients.
fsspec already implements a large catalogue of filesystems — memory, local,
HTTP, GCS, ABFS, SSH, and more. Rather than reimplement each one, this
module gives callers a tiny surface (upload / download / exists /
list_dir / delete / mkdir) over any fsspec URL. The fsspec
import is lazy so installing the package is only required when the bridge
is actually used.
This is a developer helper, not a user-input surface. Callers are
responsible for validating URLs before handing them in — there is no SSRF
guard here because fsspec supports dozens of schemes, many of which bypass
the http(s) validator entirely (ssh://, s3://, gcs://…).
- class automation_file.remote.fsspec_bridge.FsspecEntry(name, is_dir, size)[source]
Bases:
objectA single directory listing entry returned by
fsspec_list_dir().
- automation_file.remote.fsspec_bridge.fsspec_delete(url, *, recursive=False)[source]
Remove
urlfrom its fsspec filesystem.
- automation_file.remote.fsspec_bridge.fsspec_download(url, local_path)[source]
Download the fsspec resource at
urltolocal_path.
- automation_file.remote.fsspec_bridge.fsspec_exists(url)[source]
Return True if
urlexists on its backing fsspec filesystem.
- automation_file.remote.fsspec_bridge.fsspec_list_dir(url)[source]
Return a shallow listing of
urlasFsspecEntryrecords.- Parameters:
url (str)
- Return type:
- automation_file.remote.fsspec_bridge.fsspec_mkdir(url, *, create_parents=True)[source]
Create the directory at
url(optionally including parents).
- automation_file.remote.fsspec_bridge.fsspec_upload(local_path, url)[source]
Copy
local_pathonto the fsspec target aturl.
- automation_file.remote.fsspec_bridge.get_fs(url_or_protocol, **storage_options)[source]
Return an
fsspec.AbstractFileSystemforurl_or_protocol.Pass either a bare protocol (
"s3","memory") or a full URL — fsspec’surl_to_fswill extract the protocol and passstorage_optionsthrough to the backend constructor.
Cross-backend
Cross-backend copy — stream a file from one storage backend to another.
copy_between(source, target) resolves each URI to (backend, parameters),
downloads the source to a private temp file, then uploads from that temp
file to the target. Every backend already exposes *_download_file /
*_upload_file primitives — this module just picks the right pair and
cleans up the intermediate temp file.
Supported URI schemes:
local:/absolute/pathor a bare filesystem paths3://bucket/keyazure://container/blobdropbox:/pathsftp:/remote/pathftp:/remote/pathhttp://.../https://...(source only)
Callers must have previously initialised every backend they reference
(s3_instance.later_init, etc.) — this helper does not manage sessions.
- exception automation_file.remote.cross_backend.CrossBackendException[source]
Bases:
FileAutomationExceptionRaised when a URI is malformed or refers to an unknown backend.