You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
name:"addMD5ChecksumForDeleteObjects", // Optional: Name it whatever you'd like
66
+
tags: ["MD5_FALLBACK"],
67
+
});
67
68
68
69
return client;
69
70
}
@@ -98,15 +99,15 @@ try {
98
99
99
100
## How It Works
100
101
101
-
The solution adds middleware to the S3 client that:
102
+
The solution adds middleware to the S3 client's stack using `addRelativeTo`. This ensures the custom middleware executes at the correct point in the request lifecycle:
102
103
103
-
1. Detects DeleteObjects operations using the command name
104
-
2.Lets the SDKadd its default headers
105
-
3.Removes any checksumheaders in the finalizeRequest step
106
-
4.Calculates an MD5 hash of the request body
107
-
5.Adds the MD5 hash as a Content-MD5 header
104
+
1.Detects `DeleteObjects` operations using the command name.
105
+
2. It's placed **after**the SDK's default `flexibleChecksumsMiddleware`. This allows the default middleware to potentially add its checksum headers first (usually in the `build` step).
106
+
3. The custom middleware then **removes**any `x-amz-checksum-*` or `x-amz-sdk-checksum-*`headers that might have been added.
107
+
4. It calculates an MD5 hash of the request body.
108
+
5. It adds the MD5 hash as a `Content-MD5` header.
108
109
109
-
This sequence ensures that we properly replace the checksums with MD5 checksum.
110
+
This sequence ensures that we reliably replace the default checksums with `Content-MD5` specifically for `DeleteObjects` operations before the request is signed and sent.
0 commit comments