add proof of concept sftp downloader

This commit is contained in:
rebuilt 2022-12-27 14:19:49 -08:00
parent 46e3d98172
commit 6f986ff8a1
3 changed files with 37 additions and 0 deletions

View file

@ -0,0 +1,26 @@
require 'net/sftp'
require 'uri'
require 'csv'
module Sftp
class Downloader
def initialize
sftptogo_url = ENV['SFTPTOGO_URL']
uri = URI.parse(sftptogo_url)
Net::SFTP.start(uri.host, uri.user, password: uri.password) do |sftp|
# download a file or directory from the remote host
# open and read from a pseudo-IO for a remote file
# sftp.file.open('/mciea/data/canary.csv', 'r') do |f|
# CSV.parse(f.read) do |row|
# puts row
# end
# end
# list the entries in a directory
sftp.dir.foreach('/mciea/data/') do |entry|
puts entry.longname
end
end
end
end
end