Skip to content

Commit

Permalink
Few fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
durch committed Dec 19, 2022
1 parent 73a9476 commit a3956be
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
4 changes: 4 additions & 0 deletions examples/sync-backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use awscreds::Credentials;
use s3::error::S3Error;
use s3::Bucket;

#[cfg(feature = "sync")]
fn main() -> Result<(), S3Error> {
let bucket = Bucket::new(
"rust-s3-test",
Expand Down Expand Up @@ -35,3 +36,6 @@ fn main() -> Result<(), S3Error> {
assert_eq!(response_data.status_code(), 204);
Ok(())
}

#[cfg(not(feature = "sync"))]
fn main() {}
22 changes: 19 additions & 3 deletions s3/src/bucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -914,10 +914,17 @@ impl Bucket {
/// let path = "path";
/// let test: Vec<u8> = (0..1000).map(|_| 42).collect();
/// let mut file = File::create(path)?;
/// // tokio open file
/// let mut async_output_file = tokio::fs::File::create("async_output_file").await.expect("Unable to create file");
/// file.write_all(&test)?;
///
/// // Generic over std::io::Read
/// let status_code = bucket.put_object_stream(&mut file, "/path").await?;
/// #[cfg(feature = "with-tokio")]
/// let status_code = bucket.put_object_stream(&mut async_output_file, "/path").await?;
///
///
/// #[cfg(feature = "with-async-std")]
/// let mut async_output_file = async_std::fs::File::create("async_output_file").await.expect("Unable to create file");
///
/// // `sync` feature will produce an identical method
/// #[cfg(feature = "sync")]
Expand Down Expand Up @@ -982,10 +989,16 @@ impl Bucket {
/// let mut file = File::create(path)?;
/// file.write_all(&test)?;
///
/// #[cfg(feature = "with-tokio")]
/// let mut async_output_file = tokio::fs::File::create("async_output_file").await.expect("Unable to create file");
///
/// #[cfg(feature = "with-async-std")]
/// let mut async_output_file = async_std::fs::File::create("async_output_file").await.expect("Unable to create file");
///
/// // Async variant with `tokio` or `async-std` features
/// // Generic over std::io::Read
/// let status_code = bucket
/// .put_object_stream_with_content_type(&mut file, "/path", "application/octet-stream")
/// .put_object_stream_with_content_type(&mut async_output_file, "/path", "application/octet-stream")
/// .await?;
///
/// // `sync` feature will produce an identical method
Expand Down Expand Up @@ -1124,7 +1137,7 @@ impl Bucket {
.into_iter()
.enumerate()
.map(|(i, x)| Part {
etag: x,
etag: x.replace('"', ""),
part_number: i as u32 + 1,
})
.collect::<Vec<Part>>();
Expand Down Expand Up @@ -2620,7 +2633,10 @@ mod test {
init();
let remote_path = "+stream_test_small";
let content: Vec<u8> = object(1000);
#[cfg(feature = "with-tokio")]
let mut reader = std::io::Cursor::new(&content);
#[cfg(feature = "with-async-std")]
let mut reader = async_std::io::Cursor::new(&content);

let code = bucket
.put_object_stream(&mut reader, remote_path)
Expand Down
2 changes: 1 addition & 1 deletion s3/src/request/request_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ pub trait Request {
Vec::from(content)
} else if let Command::CompleteMultipartUpload { data, .. } = &self.command() {
let body = data.to_string();
// assert_eq!(body, "body".to_string());
println!("CompleteMultipartUpload: {}", body);
body.as_bytes().to_vec()
} else if let Command::CreateBucket { config } = &self.command() {
if let Some(payload) = config.location_constraint_payload() {
Expand Down

0 comments on commit a3956be

Please sign in to comment.