diff --git a/core/src/layers/correctness_check.rs b/core/src/layers/correctness_check.rs index b3a08f8970fe..bc09dbf37441 100644 --- a/core/src/layers/correctness_check.rs +++ b/core/src/layers/correctness_check.rs @@ -122,12 +122,16 @@ impl LayeredAccess for CorrectnessAccessor { "if_not_exists", )); } - if args.if_none_match().is_some() && !capability.write_with_if_none_match { - return Err(new_unsupported_error( - self.info.as_ref(), - Operation::Write, - "if_none_match", - )); + if let Some(if_none_match) = args.if_none_match() { + // AWS S3 supports only wildcard (every resource) matching + let is_s3_wildcard_match = self.info.scheme() == Scheme::S3 && if_none_match == "*"; + if !is_s3_wildcard_match || !capability.write_with_if_none_match { + return Err(new_unsupported_error( + self.info.as_ref(), + Operation::Write, + "if_none_match", + )); + } } self.inner.write(path, args).await diff --git a/core/src/services/s3/core.rs b/core/src/services/s3/core.rs index f8140c5e230b..4c70757068c6 100644 --- a/core/src/services/s3/core.rs +++ b/core/src/services/s3/core.rs @@ -465,7 +465,7 @@ impl S3Core { req = req.header(IF_MATCH, if_match); } - if args.if_not_exists() { + if args.if_not_exists() || args.if_none_match() == Some("*") { req = req.header(IF_NONE_MATCH, "*"); }