Loading aws/sdk/examples/s3-helloworld/Cargo.toml 0 → 100644 +16 −0 Original line number Diff line number Diff line [package] name = "s3-helloworld" version = "0.1.0" authors = ["Russell Cohen <rcoh@amazon.com>"] edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] s3 = { package = "aws-sdk-s3", path = "../../build/aws-sdk/s3" } smithy-http = { path = "../../build/aws-sdk/smithy-http" } tokio = { version = "1", features = ["full"] } tracing-subscriber = "0.2.18" [profile.dev] split-debuginfo = "unpacked" aws/sdk/examples/s3-helloworld/src/main.rs 0 → 100644 +40 −0 Original line number Diff line number Diff line use s3::Region; use smithy_http::byte_stream::ByteStream; use std::error::Error; use std::path::Path; use tracing_subscriber::fmt::format::FmtSpan; use tracing_subscriber::fmt::SubscriberBuilder; // Change these to your bucket & key const BUCKET: &str = "demo-bucket"; const KEY: &str = "demo-object"; #[tokio::main] async fn main() -> Result<(), Box<dyn Error>> { SubscriberBuilder::default() .with_env_filter("info") .with_span_events(FmtSpan::CLOSE) .init(); let conf = s3::Config::builder() .region(Region::new("us-east-2")) .build(); let client = s3::Client::from_conf(conf); let resp = client.list_buckets().send().await?; for bucket in resp.buckets.unwrap_or_default() { println!("bucket: {:?}", bucket.name.expect("buckets have names")) } let body = ByteStream::from_path(Path::new("Cargo.toml")).await?; let resp = client .put_object() .bucket(BUCKET) .key(KEY) .body(body) .send(); let resp = resp.await?; println!("Upload success. Version: {:?}", resp.version_id); let resp = client.get_object().bucket(BUCKET).key(KEY).send().await?; let data = resp.body.collect().await?; println!("data: {:?}", data.into_bytes()); Ok(()) } aws/sdk/models/s3-preview.json→aws/sdk/models/s3.json +68 −68 File changed and moved.Preview size limit exceeded, changes collapsed. Show changes rust-runtime/smithy-http/src/byte_stream/bytestream_util.rs +7 −7 Original line number Diff line number Diff line Loading @@ -23,20 +23,20 @@ use tokio_util::io::ReaderStream; /// 3. Provide size hint pub struct PathBody { state: State, sz: u64, len: u64, } impl PathBody { pub fn from_path(path: &Path, sz: u64) -> Self { pub fn from_path(path: &Path, len: u64) -> Self { PathBody { state: State::Unloaded(path.to_path_buf()), sz, len, } } pub fn from_file(file: File, sz: u64) -> Self { pub fn from_file(file: File, len: u64) -> Self { PathBody { state: State::Loaded(ReaderStream::new(file)), sz, len, } } } Loading Loading @@ -92,10 +92,10 @@ impl Body for PathBody { fn is_end_stream(&self) -> bool { // fast path end-stream for empty files self.sz == 0 self.len == 0 } fn size_hint(&self) -> SizeHint { SizeHint::with_exact(self.sz) SizeHint::with_exact(self.len) } } Loading
aws/sdk/examples/s3-helloworld/Cargo.toml 0 → 100644 +16 −0 Original line number Diff line number Diff line [package] name = "s3-helloworld" version = "0.1.0" authors = ["Russell Cohen <rcoh@amazon.com>"] edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] s3 = { package = "aws-sdk-s3", path = "../../build/aws-sdk/s3" } smithy-http = { path = "../../build/aws-sdk/smithy-http" } tokio = { version = "1", features = ["full"] } tracing-subscriber = "0.2.18" [profile.dev] split-debuginfo = "unpacked"
aws/sdk/examples/s3-helloworld/src/main.rs 0 → 100644 +40 −0 Original line number Diff line number Diff line use s3::Region; use smithy_http::byte_stream::ByteStream; use std::error::Error; use std::path::Path; use tracing_subscriber::fmt::format::FmtSpan; use tracing_subscriber::fmt::SubscriberBuilder; // Change these to your bucket & key const BUCKET: &str = "demo-bucket"; const KEY: &str = "demo-object"; #[tokio::main] async fn main() -> Result<(), Box<dyn Error>> { SubscriberBuilder::default() .with_env_filter("info") .with_span_events(FmtSpan::CLOSE) .init(); let conf = s3::Config::builder() .region(Region::new("us-east-2")) .build(); let client = s3::Client::from_conf(conf); let resp = client.list_buckets().send().await?; for bucket in resp.buckets.unwrap_or_default() { println!("bucket: {:?}", bucket.name.expect("buckets have names")) } let body = ByteStream::from_path(Path::new("Cargo.toml")).await?; let resp = client .put_object() .bucket(BUCKET) .key(KEY) .body(body) .send(); let resp = resp.await?; println!("Upload success. Version: {:?}", resp.version_id); let resp = client.get_object().bucket(BUCKET).key(KEY).send().await?; let data = resp.body.collect().await?; println!("data: {:?}", data.into_bytes()); Ok(()) }
aws/sdk/models/s3-preview.json→aws/sdk/models/s3.json +68 −68 File changed and moved.Preview size limit exceeded, changes collapsed. Show changes
rust-runtime/smithy-http/src/byte_stream/bytestream_util.rs +7 −7 Original line number Diff line number Diff line Loading @@ -23,20 +23,20 @@ use tokio_util::io::ReaderStream; /// 3. Provide size hint pub struct PathBody { state: State, sz: u64, len: u64, } impl PathBody { pub fn from_path(path: &Path, sz: u64) -> Self { pub fn from_path(path: &Path, len: u64) -> Self { PathBody { state: State::Unloaded(path.to_path_buf()), sz, len, } } pub fn from_file(file: File, sz: u64) -> Self { pub fn from_file(file: File, len: u64) -> Self { PathBody { state: State::Loaded(ReaderStream::new(file)), sz, len, } } } Loading Loading @@ -92,10 +92,10 @@ impl Body for PathBody { fn is_end_stream(&self) -> bool { // fast path end-stream for empty files self.sz == 0 self.len == 0 } fn size_hint(&self) -> SizeHint { SizeHint::with_exact(self.sz) SizeHint::with_exact(self.len) } }