parent
46e3d98172
commit
6f986ff8a1
@ -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…
Reference in new issue