I am trying to download a file from a bucket with Rusoto and I am getting the file content:
fn get_object(client: &TestClient, bucket: &str, filename: &str) {
let get_req = GetObjectRequest {
bucket: bucket.to_owned(),
key: filename.to_owned(),
..Default::default()
};
let result = client.get_object(&get_req).sync().expect("Couldn't GET object");
let stream = result.body.unwrap();
let body = stream.concat2().wait().unwrap();
assert!(body.len() > 0);
}
How can I save this GetObjectOutput(result)
object to a file?
You're almost there. Your code will put the object in
body
, which is aVec<u8>
.To write the contents of
body
to a file: