-
Notifications
You must be signed in to change notification settings - Fork 584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lib-storage] Upload fails if application provides checksum for >5 MB file #6742
Comments
This bug can be fixed when S3 allows passing
|
While we wait for model to updated to allow passing Workaround 1: Let SDK compute the checksumPass Test code class CustomHandler extends NodeHttpHandler {
constructor() {
super();
}
printChecksumHeaders(prefix, headers) {
for (const [header, value] of Object.entries(headers)) {
if (
header.startsWith("x-amz-checksum-") ||
header.startsWith("x-amz-sdk-checksum-")
) {
console.log(`${prefix}['${header}']: '${value}'`);
}
}
}
async handle(request, options) {
const response = await super.handle(request, options);
console.log();
console.log("------------------");
this.printChecksumHeaders("request", request.headers);
this.printChecksumHeaders("response", response.response.headers);
console.log("------------------");
console.log();
return response;
}
}
const client = new S3({ requestHandler: new CustomHandler() });
const Bucket = "test-flexible-checksums"; // Replace with your test bucket name.
const Body = createReadStream(Key);
const ChecksumAlgorithm = "SHA256";
const upload = new Upload({
client,
params: { Bucket, Key, Body, ChecksumAlgorithm },
});
await upload.done(); Note that SDK sends the 6 MB file in two parts, and computes checksums for each part ------------------
request['x-amz-checksum-algorithm']: 'SHA256'
response['x-amz-checksum-algorithm']: 'SHA256'
response['x-amz-checksum-type']: 'COMPOSITE'
------------------
------------------
request['x-amz-sdk-checksum-algorithm']: 'SHA256'
request['x-amz-checksum-sha256']: 'jl28wIE8B/50cPRez5JaVTYNlvVk39FWKapxP8KEu88='
response['x-amz-checksum-sha256']: 'jl28wIE8B/50cPRez5JaVTYNlvVk39FWKapxP8KEu88='
------------------
------------------
request['x-amz-sdk-checksum-algorithm']: 'SHA256'
request['x-amz-checksum-sha256']: 'JU0DrgdnLiihtY/7GHhqvAmJv50Va9RhaNLVwUUu9NU='
response['x-amz-checksum-sha256']: 'JU0DrgdnLiihtY/7GHhqvAmJv50Va9RhaNLVwUUu9NU='
------------------
------------------
------------------ Workaround 2: Use PutObject from client-s3 instead of Upload from lib-storageclass CustomHandler extends NodeHttpHandler {
constructor() {
super();
}
printChecksumHeaders(prefix, headers) {
for (const [header, value] of Object.entries(headers)) {
if (
header.startsWith("x-amz-checksum-") ||
header.startsWith("x-amz-sdk-checksum-")
) {
console.log(`${prefix}['${header}']: '${value}'`);
}
}
}
async handle(request, options) {
const response = await super.handle(request, options);
console.log();
console.log("------------------");
this.printChecksumHeaders("request", request.headers);
this.printChecksumHeaders("response", response.response.headers);
console.log("------------------");
console.log();
return response;
}
}
const client = new S3({ requestHandler: new CustomHandler() });
const Bucket = "test-flexible-checksums"; // Replace with your test bucket name.
const Body = createReadStream(Key);
await client.putObject({ Bucket, Key, Body, ChecksumSHA256 }); The PutObject call will send the provided checksum when making the call ------------------
request['x-amz-checksum-sha256']: 'ZRRKEcEAxGazUzgqh+rSEecXfI27XNZQ8Uv7aMOX64s='
response['x-amz-checksum-sha256']: 'ZRRKEcEAxGazUzgqh+rSEecXfI27XNZQ8Uv7aMOX64s='
response['x-amz-checksum-type']: 'FULL_OBJECT'
------------------ Between the two workarounds, we recommend using Upload without checksum, as |
Checkboxes for prior research
Describe the bug
Upload fails if application provides checksum for >5 MB file
Regression Issue
SDK version number
@aws-sdk/[email protected], @aws-sdk/[email protected]
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
All, verified in v22.11.0
Reproduction Steps
Observed Behavior
When
SIZE_IN_MB
is greater than 5, the following error is thrownWhen
SIZE_IN_MB
is less than or equal to 5, then no error is thrown.Expected Behavior
No error thrown when application provides Checksum for >5 MB file.
Possible Solution
No response
Additional Information/Context
No response
The text was updated successfully, but these errors were encountered: