I am using the net-sftp gem to download a file to memory:
sftp = Net::SFTP.start('ftp.myapp.com','user_name', :password => 'password')
records = sftp.download!("luigi/List.csv")
I then need to move my file, located remote at luigi/List.csv
and rename it.
I want to move it here:
"luigi/archive/List_#{Time.now}.csv"
I would then like to delete the original file, located at luigi/List.csv
.
How can I use ruby 2.0.0 and rails 4.0.0 to move, rename, and delete a file on my FTP site?
Use rename
:
sftp.rename("luigi/List.csv", "luigi/archive/List_#{Time.now}.csv")
assuming luigi/archive
exists.
To just delete, there is the remove
function. See the Net::SFTP FAQ.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With