Search code examples
rubysftpnet-sftp

Ruby Net/SFTP throttle speed


Is there a way to throttle the connection of a transfer with the ruby Net/SFTP library? I would like to leverage this to download some backups on a nightly basis, but don't want to eat up all of the server's bandwidth while doing so.


Solution

  • Consider this sample from the Net::SFTP documentation:

    # open and read from a pseudo-IO for a remote file
    sftp.file.open("/path/to/remote", "r") do |f|
      puts f.gets
    end
    

    What would happen if you put a sleep inside that block?