Rust
Rust
Amazon S3 Download String from Bucket in Region
See more Amazon S3 Examples
Demonstrates how to download a text file (i.e. object) from an S3 bucket NOT in the us-east-1 region.Chilkat Rust Downloads
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = chilkat::Http::new();
// Insert your access key here:
http.set_aws_access_key("AWS_ACCESS_KEY");
// Insert your secret key here:
http.set_aws_secret_key("AWS_SECRET_KEY");
// This bucket is in the eu-central-1 region.
http.set_aws_region("eu-central-1");
let bucket_name = "chilkateufrankfurt".to_string();
let object_name = "fruit.xml".to_string();
let charset = "utf-8".to_string();
let file_contents = http.s3_download_string(&bucket_name, &object_name, &charset).unwrap_or_default();
if !http.last_method_success() {
// Failed
println!("{}", http.last_error_text());
} else {
// Success
println!("{}", file_contents);
}