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
Copy file name to clipboardExpand all lines: supplemental-docs/MD5_FALLBACK.md
+15-14Lines changed: 15 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -2,13 +2,15 @@
2
2
3
3
## Background
4
4
5
-
Recently the AWS SDKs shipped a feature that [changed default object integrity in S3](https://github.com/aws/aws-sdk-js-v3/issues/6810). The SDKs now default to using more modern checksums (like CRC32) to ensure object integrity, whereas previously MD5 checksums were being used. Some third-party S3-compatible services currently do not support these checksums. To our knowledge, this affects only the S3 `DeleteObjects` operation.
5
+
In AWS SDK for JavaScript [v3.729.0](https://github.com/aws/aws-sdk-js-v3/releases/tag/v3.729.0), we shipped a feature that [changed default object integrity in S3](https://github.com/aws/aws-sdk-js-v3/issues/6810). The SDKs now default to using more modern checksums (like CRC32) to ensure object integrity, whereas previously MD5 checksums were being used. Some third-party S3-compatible services currently do not support these checksums. To our knowledge, this affects only the S3 `DeleteObjects` operation.
6
6
7
-
If you wish to fallback to the old behavior of sending MD5 checksums, for operations like `DeleteObjectsCommand` this is how you can do it in AWS SDK for JavaScript v3:
7
+
If you wish to fallback to the old behavior of sending MD5 checksums, for operations like `DeleteObjectsCommand` this is how
8
+
you can do it in AWS SDK for JavaScript v3:
8
9
9
10
## MD5 fallback
10
11
11
-
The following code provides a custom S3 client that will use MD5 checksums for DeleteObjects operations while maintaining the default behavior for all other operations.
12
+
The following code provides a custom S3 client that will use MD5 checksums for DeleteObjects operations while maintaining the
13
+
default behavior for all other operations.
12
14
13
15
```javascript
14
16
// md5ClientS3.mjs
@@ -20,19 +22,18 @@ import { createHash } from "crypto";
step:"finalizeRequest",// Run after all other request modifications
58
+
step:"finalizeRequest",
59
59
name:"addMD5Checksum",
60
60
}
61
61
);
@@ -95,13 +95,13 @@ try {
95
95
96
96
The solution adds middleware to the S3 client that:
97
97
98
-
1. Detects DeleteObjects operations
98
+
1. Detects DeleteObjects operations using the command name
99
99
2. Lets the SDK add its default headers
100
100
3. Removes any checksum headers in the finalizeRequest step
101
101
4. Calculates an MD5 hash of the request body
102
102
5. Adds the MD5 hash as a Content-MD5 header
103
103
104
-
This sequence ensures that we properly replace the current checksums with the MD5 checksum.
104
+
This sequence ensures that we properly replace the checksums with MD5 checksum.
105
105
106
106
## Usage Notes
107
107
@@ -110,7 +110,8 @@ This sequence ensures that we properly replace the current checksums with the MD
110
110
111
111
## Debugging
112
112
113
-
To verify that the MD5 checksum is being correctly applied, you can add console logging to the middleware by modifying the code to include logging statements:
113
+
To verify that the MD5 checksum is being correctly applied, you can add console logging to the middleware by modifying the
0 commit comments