I am working on an integration that requires my Rails 4 app to push a CSV to an SFTP server daily. The app will eventually live on Heroku.
I am using the 'net-sftp' gem.
Moving the file via FTP client (FileZilla) works.
Here's the very simple class I'm trying to use:
require 'net/ssh'
require 'net/sftp'
class SFTP
def initialize(org)
case org
when 'client'
@host = ENV['HOST']
@username = ENV['USERNAME']
@password = ENV['PASSWORD']
@port = ENV['PORT']
end
end
def send(local_path)
Net::SFTP.start(@host, @username , { password: @password, port: @port } ) do |sftp|
sftp.upload!(local_path, "/files")
end
end
end
Here is the error I get:
Net::SFTP::StatusException: Net::SFTP::StatusException open /files (3, "permission denied")
/net-sftp-2.1.2/lib/net/sftp/operations/upload.rb:321:in `on_open'
/net-sftp-2.1.2/lib/net/sftp/request.rb:87:in `call'
/net-sftp-2.1.2/lib/net/sftp/request.rb:87:in `respond_to'
/net-sftp-2.1.2/lib/net/sftp/session.rb:948:in `dispatch_request'
/net-sftp-2.1.2/lib/net/sftp/session.rb:911:in `when_channel_polled'
I've also tried '~/'
, '~'
and '~/files'
as the remote path, all of which I have access too.