-
Notifications
You must be signed in to change notification settings - Fork 597
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
CompleteMultipartUploadCommand missing IfMatch types #6795
Comments
Hey @DarthCoder117 , I can't reproduce this issue and I will post my code&result in another comment.
Here's my suggestion - Please run the command to reinstall the latest version package and build the application. rm -rf node_modules/
npm install Run the app, see if the error persists. |
Code I have - import {
S3Client,
CreateMultipartUploadCommand,
UploadPartCommand,
CompleteMultipartUploadCommand
} from "@aws-sdk/client-s3";
async function performMultipartUpload(bucketName, key, fileData) {
const s3Client = new S3Client({ region: "us-east-1" });
let uploadId;
const uploadedParts = [];
try {
// 1. Start the multipart upload to get an upload ID
const createResponse = await s3Client.send(new CreateMultipartUploadCommand({
Bucket: bucketName,
Key: key
}));
uploadId = createResponse.UploadId;
console.log("Started upload with ID:", uploadId);
// 2. Upload parts (simplified example)
const partSize = 5 * 1024 * 1024; // 5MB minimum size
for (let i = 0; i < fileData.length; i += partSize) {
const chunk = fileData.slice(i, i + partSize);
const partNumber = Math.floor(i / partSize) + 1;
const uploadResponse = await s3Client.send(new UploadPartCommand({
Bucket: bucketName,
Key: key,
UploadId: uploadId,
PartNumber: partNumber,
Body: chunk
}));
uploadedParts.push({
PartNumber: partNumber,
ETag: uploadResponse.ETag
});
}
// 3. Complete the multipart upload
const completeResponse = await s3Client.send(new CompleteMultipartUploadCommand({
Bucket: bucketName,
Key: key,
UploadId: uploadId,
MultipartUpload: {
Parts: uploadedParts.sort((a, b) => a.PartNumber - b.PartNumber)
},
IfNoneMatch: '*'
}));
return completeResponse;
} catch (error) {
console.error("Upload failed:", error);
throw error;
}
}
// Example usage
const exampleData = Buffer.from("Example file content");
performMultipartUpload(
"my-bucket",
"example.txt",
exampleData
)
.then(result => console.log("Success:", result))
.catch(error => console.error("Error:", error));
result I got
|
Just cleared my |
This issue is now closed. Comments on closed issues are hard for our team to see. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread. |
Checkboxes for prior research
Describe the bug
Trying to use
CompleteMultipartUploadCommand
with conditional requests I noticed theIfMatch
andIfNoneMatch
fields are visible in the API reference, but not available in the actual package.I assumed it must be that my SDK is outdated, so I tried updating to the latest version but nothing changed.
I also checked to see that the same issue affects the
PutObjectCommand
as well.https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/s3/command/CompleteMultipartUploadCommand/
https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/s3/command/PutObjectCommand/
Regression Issue
SDK version number
@aws-sdk/[email protected]
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
v20.11.1
Reproduction Steps
Try to instantiate a
CompleteMultipartUploadCommand
using eitherIfMatch
orIfNoneMatch
Observed Behavior
You get type errors:
Expected Behavior
You shouldn't get type errors.
Possible Solution
No response
Additional Information/Context
I believe this bug was likely not noticed because using a separate input object dodges the type error.
This works fine:
The text was updated successfully, but these errors were encountered: