diff --git a/services/aliyun-oss/src/sign_request.rs b/services/aliyun-oss/src/sign_request.rs index cdc48025..7884ad89 100644 --- a/services/aliyun-oss/src/sign_request.rs +++ b/services/aliyun-oss/src/sign_request.rs @@ -321,7 +321,15 @@ impl RequestSigner { // Build resource string let decoded_path = percent_encoding::percent_decode_str(path).decode_utf8_lossy(); - let resource_path = format!("/{}{}", self.bucket, decoded_path); + let authority = req.uri.authority().map(|v| v.as_str()).unwrap_or(""); + let is_virtual_host = authority.starts_with(&format!("{}.", self.bucket)); + + let resource_path = if is_virtual_host { + format!("/{}{}", self.bucket, decoded_path) + } else { + // Path-style addressing already includes bucket in request path: http://endpoint//, do not repeat + decoded_path.to_string() + }; if query_pairs.is_empty() { resource_path