From 33249717010b1173fc28ba188e5fe6d580fbf393 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 1 May 2020 14:30:50 +0000 Subject: Slightly improved S3 compatibility - ListBucket does not require any of the parameters (delimiter, prefix, max-keys, etc) - URLs are properly percent_decoded - PutObject and DeleteObject calls now answer correctly (empty body, version id in the x-amz-version-id: header) --- src/api/s3_list.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/api/s3_list.rs') diff --git a/src/api/s3_list.rs b/src/api/s3_list.rs index ffde609f..df792da2 100644 --- a/src/api/s3_list.rs +++ b/src/api/s3_list.rs @@ -29,6 +29,7 @@ pub async fn handle_list( ) -> Result, Error> { let mut result_keys = BTreeMap::::new(); let mut result_common_prefixes = BTreeSet::::new(); + let mut truncated = true; let mut next_chunk_start = marker.unwrap_or(prefix).to_string(); @@ -44,12 +45,19 @@ pub async fn handle_list( max_keys, ) .await?; + debug!( + "List: get range {} (max {}), results: {}", + next_chunk_start, + max_keys, + objects.len() + ); + for object in objects.iter() { + if !object.key.starts_with(prefix) { + truncated = false; + break; + } if let Some(version) = object.versions().iter().find(|x| x.is_data()) { - if !object.key.starts_with(prefix) { - truncated = false; - break; - } let common_prefix = if delimiter.len() > 0 { let relative_key = &object.key[prefix.len()..]; match relative_key.find(delimiter) { @@ -117,7 +125,7 @@ pub async fn handle_list( for pfx in result_common_prefixes.iter() { writeln!( &mut xml, - "\t{}", + "\t\t{}", xml_escape(pfx), //xml_encode_key(pfx, urlencode_resp) ) @@ -126,6 +134,7 @@ pub async fn handle_list( writeln!(&mut xml, "\t").unwrap(); } writeln!(&mut xml, "").unwrap(); + println!("{}", xml); Ok(Response::new(Box::new(BytesBody::from(xml.into_bytes())))) } -- cgit v1.2.3