SFTP transport wrapper that writes data to a local temporary file using a delegate exporter, then uploads the result via SFTP.
The delegate exporter is automatically selected based on the remote filename extension (e.g., .csv uses ObjDataExportCsv, .json uses ObjDataExportJson). All WriteHeader and WriteData calls are forwarded to the delegate. On CloseFile, the delegate finalises the local file and the wrapper uploads it to the SFTP server, then removes the temporary file.
SFTP credentials are resolved in priority order:
sftp:// URI set on self.sftp_urisftp_host, sftp_port, sftp_username, sftp_password, sftp_private_keysftp section in config.yamlpysftp (listed in requirements.txt)from ObjDataExportSftp import ObjExportApi
exporter = ObjExportApi()
exporter.sftp_uri = "sftp://user:pass@host.example.com:22"
exporter.OpenFile("/remote/path/export.csv")
exporter.WriteHeader(["Name", "Score"])
exporter.WriteData([["Alice", "95"], ["Bob", "82"]])
exporter.CloseFile()
| Method | Description |
|---|---|
OpenFile(filename) |
Detect extension, create delegate and temp file |
WriteHeader(fields) |
Store headers and delegate to inner exporter |
WriteData(data) |
Delegate to inner exporter |
CloseFile() |
Close delegate, upload via SFTP, clean up temp file |
EscapeCSV(val) |
Delegates to inner exporter |
DefaultExtension() |
Returns "" (determined by delegate) |