Project

lex-sftp

0.0
No release in over 3 years
LEX::SFTP — SFTP file transfer for LegionIO (healthcare HL7, EDI, FHIR)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

 Project Readme

lex-sftp

SFTP file transfer for LegionIO. Upload, download, and manage files on SFTP servers from within task chains. Designed for healthcare file exchange (HL7, EDI, FHIR bundles).

Installation

gem install lex-sftp

Or add to your Gemfile:

gem 'lex-sftp'

Runners

FileOps

Method Parameters Description
upload local_path:, remote_path:, **opts Upload a file to the SFTP server
download remote_path:, local_path:, **opts Download a file from the SFTP server
delete remote_path:, **opts Remove a file from the SFTP server
rename old_path:, new_path:, **opts Rename or move a remote file
stat remote_path:, **opts Get file attributes (size, mtime, permissions)

All methods return { success: true/false, ... } hashes.

Directory

Method Parameters Description
list remote_path:, **opts List directory entries
mkdir remote_path:, **opts Create a remote directory
rmdir remote_path:, **opts Remove a remote directory
entries remote_path:, pattern: nil, **opts Filtered directory listing (glob pattern)

Transfer

Method Parameters Description
batch_upload files:, remote_dir:, **opts Upload an array of local file paths
batch_download files:, local_dir:, **opts Download an array of remote file paths
sync local_dir:, remote_dir:, direction: :upload, **opts Sync a directory (:upload or :download)

Authentication

Pass authentication kwargs alongside other parameters:

Parameter Description
host SFTP server hostname or IP
user SFTP username (default: 'sftp')
port SFTP port (default: 22)
password Password authentication
key_path Path to private key file
key_data Inline private key data
timeout Connection timeout in seconds (default: 30)

Standalone Client

Use Legion::Extensions::Sftp::Client outside the full LegionIO framework.

require 'legion/extensions/sftp'

client = Legion::Extensions::Sftp::Client.new(
  host:     'sftp.clearinghouse.example.com',
  user:     'hl7_sender',
  key_path: '/etc/legion/sftp_key'
)

# Upload HL7 message
client.upload(local_path: '/tmp/ADT_A01_20240101.hl7', remote_path: '/inbound/ADT_A01_20240101.hl7')

# List outbound results
result = client.entries(remote_path: '/outbound', pattern: '*.hl7')
result[:entries].each { |e| puts e[:name] }

# Download all results
client.sync(local_dir: '/tmp/results', remote_dir: '/outbound', direction: :download)

Constructor: Client.new(**opts). All kwargs are stored and passed through to Net::SFTP on each call.

Requirements

  • Ruby >= 3.4
  • SFTP server access
  • net-sftp ~> 4.0

License

MIT