add proof of concept sftp downloader

pull/1/head
rebuilt 3 years ago
parent eeeb4f5d14
commit 1426e7cc63

@ -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.0)
better_html (1.0.16)
actionview (>= 4.0)
@ -132,6 +133,7 @@ GEM
diff-lcs (1.5.0)
docile (1.4.0)
e2mmap (0.1.0)
ed25519 (1.3.0)
erb_lint (0.1.3)
activesupport
better_html (~> 1.0.7)
@ -204,8 +206,11 @@ GEM
net-protocol
net-protocol (0.1.3)
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.8.0)
nio4r (2.5.8)
nokogiri (1.13.10)
@ -408,6 +413,7 @@ PLATFORMS
DEPENDENCIES
activerecord-import
apparition!
bcrypt_pbkdf
bootsnap
brakeman
bullet
@ -417,6 +423,7 @@ DEPENDENCIES
database_cleaner
debug
devise
ed25519
erb_lint
erblint-github
factory_bot_rails
@ -428,6 +435,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