Thanks to Ruby’s 'net/ftp' library this gem would come in handy if you want to upload files or directories to a remote server with FTP.
gem install iam_ftp
require 'iam_ftp'
to initialize
connect = IamFtp::FtpCalls.new({:ftp_host => "ftp.iamfree.com", :ftp_username => "me@iamfree.com", :ftp_password => "i dont know"})
To upload an entire directory to server FTP
connect.upload_directory_to_ftp_server("/Users/me/Documents/work/iamnotfree/my-site/", "/home/www/")
If the server is a shared host like Godaddy.com hosting: leave second parameter blank
connect.upload_directory_to_ftp_server("/Users/me/Documents/work/iamnotfree/my-site/", "")
To upload a file one by one(firsly the directory, then the remote directory, then the file name)
connect.upload_file_to_ftp_server("/Users/me/Documents/work/iamnotfree/my-site", "", "/Users/me/Documents/work/iamnotfree/my-site/messages.html")
If it is too hard to type the file path. Just locate the file in "finder" and drag it to your terminal. That would get your file path on to the terminal.
To list all the files in your FTP server
connect.list_all_files
- Fork it ( https://github.com/iamfree-com/iam_ftp/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request