I am trying to upload a file to a server using the Net::SFTP gem. My code is as follows:
remote_path = "path/of/remote/file.txt"
local_path = "path/to/local/file.txt"
Net::SFTP.start("SERVER", "USER", :password => "PASSWORD") do |sftp|
sftp.upload!(local_path, remote_path)
end
When I execute this I get:
Net::SFTP::StatusException (Net::SFTP::StatusException open path/of/remote/file.txt (2, "no such file"))
I think the issue is that the entire remote_path of the directories doesn't exist yet. If I give it a path of directories that do exist, it will create the directories. I want the upload to also create the directories in the path if they don't exist yet. Is this indeed the issue, and if so, how can I create the directories with SFTP?
you will have to create the directory first