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
When uploading a large file (~500 MB) to S3 using the @aws-sdk/lib-storage package, the upload fails with the error:
The XML you provided was not well-formed or did not validate against our published schema
The issue appears to occur during a multipart upload, specifically when using a Readable stream as the file's body. Smaller files upload successfully, and the problem seems related to the interaction between the stream provided and the configured partSize. When I set chunk size over 500 MB it works without any problem.
Details of the browser/Node.js/ReactNative version
v23.5.0
Reproduction Steps
const s3Client = new S3Client({ region: "us-east-1" });
export async function uploadFileToS3(bucket, file) {
// Simulate a Readable stream (replace this with your actual stream source)
const stream = new Readable({
read() {
this.push(Buffer.alloc(1024 * 1024 * 500));
this.push(null);
},
});
if (!stream) {
throw new Error("Stream is empty");
}
const uploadParams = {
Bucket: bucket,
Key: file.uuid,
Body: stream, // The stream to upload
ContentType: "application/pdf", // Simplified content type
ContentLength: file.size, // Expected file size
};
const upload = new Upload({
client: s3Client,
params: uploadParams,
queueSize: 4,
partSize: 5 * 1024 * 1024,
});
upload.on("httpUploadProgress", (progress) => {
console.log(`Progress: ${progress.loaded}/${progress.total} bytes`);
});
try {
console.log("Uploading file to S3...");
const result = await upload.done();
console.log("Upload complete:", result);
} catch (err) {
console.error("Upload error:", err);
}
}
Observed Behavior
[handleConversion] pUCV6phH120ZruXxV3uzqXzBvQgWHwnGcVK5hrGm: Error during conversion process The XML you provided was not well-formed or did not validate against our published schema
Error: The XML you provided was not well-formed or did not validate against our published schema
at Worker.<anonymous> (file:///app/dist/alexandria/server.js:1061:16)
at Worker.emit (node:events:507:28)
at MessagePort.<anonymous> (node:internal/worker:267:53)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:827:20)
at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28)
at MessagePort.callbackTrampoline (node:internal/async_hooks:130:17)
Expected Behavior
I expected the file to be uploaded in chunks, and assembled by s3.
Possible Solution
No response
Additional Information/Context
No response
The text was updated successfully, but these errors were encountered:
HI @arthikek - thanks for reaching out. It sounds like the issue was resolved with the package/version update? Could you elaborate what you found?
For upload progress, are you able to see progress.loaded? It may be because ContentLength is specified in your use case when working with stream. You may try using Buffer instead of stream to see if you get the progress.total. Let us know.
aBurmeseDev
added
response-requested
Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.
p2
This is a standard priority issue
and removed
needs-triage
This issue or PR still needs to be triaged.
labels
Jan 29, 2025
Hi thanks for helping me out. I choose to use the ContentLength provided from our database. So it's fine for now. Updating the package did the job. And it's working fine. Another question, I am uploading a 500mb file with this setup to s3. I noticed some CPU spikes up to 50% of my docker container during that upload. Does this has to do with the encryption happening due to multipart upload?
Checkboxes for prior research
Describe the bug
When uploading a large file (~500 MB) to S3 using the @aws-sdk/lib-storage package, the upload fails with the error:
The XML you provided was not well-formed or did not validate against our published schema
The issue appears to occur during a multipart upload, specifically when using a Readable stream as the file's body. Smaller files upload successfully, and the problem seems related to the interaction between the stream provided and the configured partSize. When I set chunk size over 500 MB it works without any problem.
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
v23.5.0
Reproduction Steps
Observed Behavior
Expected Behavior
I expected the file to be uploaded in chunks, and assembled by s3.
Possible Solution
No response
Additional Information/Context
No response
The text was updated successfully, but these errors were encountered: