Skip to content
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

[object_store] Fix empty Multipart Upload for AWS S3 #5405

Merged
merged 2 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions object_store/src/aws/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,16 @@ impl S3Client {
upload_id: &str,
parts: Vec<PartId>,
) -> Result<PutResult> {
let parts = if parts.is_empty() {
// If no parts were uploaded, upload an empty part
// otherwise the completion request will fail
let part = self
.put_part(location, &upload_id.to_string(), 0, Bytes::new())
.await?;
vec![part]
} else {
parts
};
let request = CompleteMultipartUpload::from(parts);
let body = quick_xml::se::to_string(&request).unwrap();

Expand Down
15 changes: 15 additions & 0 deletions object_store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2200,6 +2200,21 @@ mod tests {

let meta = storage.head(&path).await.unwrap();
assert_eq!(meta.size, chunk_size * 2);

// Empty case
let path = Path::from("test_empty_multipart");

let id = multipart.create_multipart(&path).await.unwrap();

let parts = vec![];

multipart
.complete_multipart(&path, &id, parts)
.await
.unwrap();

let meta = storage.head(&path).await.unwrap();
assert_eq!(meta.size, 0);
}

#[cfg(any(feature = "azure", feature = "aws"))]
Expand Down
Loading