title: "permission denied" when uploading a file with Rails SFTP
body: <p>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.</p>
  
  <p>I am using the 'net-sftp' gem.  </p>
  
  <p>Moving the file via FTP client (FileZilla) works.</p>
  
  <p>Here's the very simple class I'm trying to use: </p>
  
  <pre><code>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
  </code></pre>
  
  <p>Here is the error I get:</p>
  
  <pre class="lang-none prettyprint-override"><code>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'
  </code></pre>
  
  <p>I've also tried <code>'~/'</code>, <code>'~'</code> and <code>'~/files'</code> as the remote path, all of which I have access too.  </p>