add proof of concept sftp downloader

mciea-main
rebuilt 3 years ago
parent 46e3d98172
commit 6f986ff8a1

@ -55,6 +55,9 @@ gem 'stimulus-rails'
gem 'watir'
gem 'selenium-webdriver', '~> 4.4'
gem 'net-sftp'
gem 'ed25519'
gem 'bcrypt_pbkdf'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console

@ -82,6 +82,7 @@ GEM
ast (2.4.2)
backport (1.2.0)
bcrypt (3.1.18)
bcrypt_pbkdf (1.1.0)
benchmark (0.2.1)
better_html (2.0.1)
actionview (>= 6.0)
@ -131,6 +132,7 @@ GEM
diff-lcs (1.5.0)
docile (1.4.0)
e2mmap (0.1.0)
ed25519 (1.3.0)
erb_lint (0.3.1)
activesupport
better_html (>= 2.0.1)
@ -207,8 +209,11 @@ GEM
net-protocol
net-protocol (0.2.1)
timeout
net-sftp (4.0.0)
net-ssh (>= 5.0.0, < 8.0.0)
net-smtp (0.3.3)
net-protocol
net-ssh (7.0.1)
newrelic_rpm (8.16.0)
nio4r (2.5.8)
nokogiri (1.14.2-x86_64-darwin)
@ -413,6 +418,7 @@ PLATFORMS
DEPENDENCIES
activerecord-import
apparition!
bcrypt_pbkdf
bootsnap
brakeman
bullet
@ -422,6 +428,7 @@ DEPENDENCIES
database_cleaner
debug
devise
ed25519
erb_lint
erblint-github
factory_bot_rails
@ -433,6 +440,7 @@ DEPENDENCIES
launchy
listen (~> 3.0.5)
nested_scaffold
net-sftp
newrelic_rpm
nokogiri (>= 1.13.4)
omniauth

@ -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
Loading…
Cancel
Save