title: Streamed upload to s3 with rusoto
body: <p>How can I upload file to s3 using <a href="https://github.com/rusoto/rusoto" rel="noreferrer">rusoto</a>, without reading file content to memory (streamed)?</p>
  
  <hr>
  
  <p>With this code:</p>
  
  <pre><code>use std::fs::File;
  use std::io::BufReader;
  
  use rusoto_core::Region;
  use rusoto_s3::{PutObjectRequest, S3, S3Client, StreamingBody};
  
  fn main() {
      let file = File::open("input.txt").unwrap();
      let mut reader = BufReader::new(file);
  
      let s3_client = S3Client::new(Region::UsEast1);
      let result = s3_client.put_object(PutObjectRequest {
          bucket: String::from("example_bucket"),
          key: "example_filename".to_string(),
  //        this works:
  //      body: Some("example string".to_owned().into_bytes().into()),
  //        this doesn't:
          body: Some(StreamingBody::new(reader)),
          ..Default::default()
      }).sync().expect("could not upload");
  }
  </code></pre>
  
  <p>I receive the following error:</p>
  
  <blockquote>
  <pre><code>error[E0277]: the trait bound `std::io::BufReader&lt;std::fs::File&gt;: futures::stream::Stream` is not satisfied
    --&gt; src/bin/example.rs:18:20
     |
  18 |         body: Some(StreamingBody::new(reader)),
     |                    ^^^^^^^^^^^^^^^^^^ the trait `futures::stream::Stream` is not implemented for `std::io::BufReader&lt;std::fs::File&gt;`
     |
     = note: required by `rusoto_core::stream::ByteStream::new`
  </code></pre>
  </blockquote>