Rust
Rust
S3 Download String Object
See more Amazon S3 Examples
Demonstrates how to download a text file (i.e. object) from the Amazon S3 service directly into an in-memory string variable.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 us-east-1 region.
http.set_aws_region("us-east-1");
let bucket_name = "chilkat-test-bucket".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);
}