Sample code for 30+ languages & platforms
Rust

FTP Bandwidth Throttle for Upload

See more FTP Examples

Demonstrates the Chilkat FTP2 upload bandwidth throttling property : BandwidthThrottleUp.

Chilkat Rust Downloads

Rust

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

let ftp = chilkat::Ftp2::new();

ftp.set_hostname("ftp.example.com");
ftp.set_username("login");
ftp.set_password("password");

// To use FTP upload bandwidth throttling, set the BandwidthThrottleUp
// property to a maximum desired bytes/second:
// This example limits the upload to 10K per second.
ftp.set_bandwidth_throttle_up(10000);

// Connect and login to the FTP server.
if ftp.connect().is_err() {
    println!("{}", ftp.last_error_text());
    return;
}

// Upload a file.
let local_filename = "hamlet.xml".to_string();
let remote_filename = "hamlet.xml".to_string();

if ftp.put_file(&local_filename, &remote_filename).is_err() {
    println!("{}", ftp.last_error_text());
    return;
}

let _ = ftp.disconnect().is_ok();

println!("File Uploaded!");