You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sqm-dashboards/app/services/sftp/downloader.rb

27 lines
690 B

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