0

I have a rails 3.2.2 app that's got the net-sftp gem installed on it.

I've created a simple controller to test the most basic feature of uploading a file to remote sftp.

This is my controller:

class UploadsController < ApplicationController
  require 'net/sftp'

  def upload
    Net::SFTP.start('host', 'root', :password => 'password') do |sftp|
      @sftp = sftp # I've got a session object so that seems to work

      # upload a file or directory to the remote host
      sftp.upload!("/Users/kensodev/Desktop/ashrit.xml", "/domains/inbar-paz.com/html/test/ashrit.xml")
    end
  end
end

When I visit "localhost:3000/uploads/upload" path I get this error:

Net::SFTP::StatusException open /domains/inbar-paz.com/html/test/ashrit.xml (2, "no such file")

Maybe I got the paths wrong?

Thanks you for trying to help :) Paz.

Paz Aricha
  • 398
  • 1
  • 5
  • 14
  • Did you test this code from the console first? It does look like a simple path error like you suspect. – Casper Jun 21 '12 at 08:32
  • I'm not sure how to test this from the console... I pasted the same code but got the same error. – Paz Aricha Jun 21 '12 at 08:49
  • 1
    You need to manually log into the sftp server to check the path. You should run `sftp` from the command line, log into the server, and see what the correct path is. Example `sftp user@host`. Note this is not from the console, but from the command line (Linux). – Casper Jun 21 '12 at 08:53
  • Thanks casper, you were right, it was the wrong remote path. Thank you. – Paz Aricha Jun 21 '12 at 09:20

1 Answers1

2

One of the directories in this path "/domains/inbar-paz.com/html/test/" doesn't not exist.

Roman
  • 13,100
  • 2
  • 47
  • 63
  • Thanks roman but that's a bit not accurate, the problem was I was missing some directories before the "/domains/" but thanks to Casper it was already solved. – Paz Aricha Jun 21 '12 at 12:11