fix: return versionId in CompleteMultipartUpload response (#35)

🎉 Merged! Thank you so much, @ByronLudwig!

This is exactly the kind of contribution that helps Floci grow — your work is genuinely appreciated.

If you're up for it, there's plenty more to dig into:
- 👀 Check out the open issues — some are tagged as good first steps for contributors
- 💬 If you have ideas or ran into something while working on this, feel free to open an issue or start a discussion
- 🔧 PRs for documentation, tests, and bug fixes are always welcome


Fixes hectorvent/floci#32

Co-authored-by: Byron Ludwig <byron.ludwig@iconsolutions.com>
This commit is contained in:
ByronLudwigandByron Ludwig authored and GitHub committed 2026-03-24 12:37:50 -05:00
1 parent 8053ae7c2e
commit 6e8713d9fe
2 files changed
+23 -5

No files matched your search

@@ -481,16 +481,22 @@ public class S3Controller {
if (baseUrl.endsWith("/")) {
baseUrl = baseUrl.substring(0, baseUrl.length() - 1);
}
String xml = new XmlBuilder()
XmlBuilder xmlBuilder = new XmlBuilder()
.raw("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
.start("CompleteMultipartUploadResult", AwsNamespaces.S3)
.elem("Location", baseUrl + "/" + bucket + "/" + key)
.elem("Bucket", bucket)
.elem("Key", key)
.elem("ETag", obj.getETag())
.end("CompleteMultipartUploadResult")
.build();
return Response.ok(xml).build();
.elem("ETag", obj.getETag());
if (obj.getVersionId() != null) {
xmlBuilder.elem("VersionId", obj.getVersionId());
}
String xml = xmlBuilder.end("CompleteMultipartUploadResult").build();
var resp = Response.ok(xml);
if (obj.getVersionId() != null) {
resp.header("x-amz-version-id", obj.getVersionId());
}
return resp.build();
}
return xmlErrorResponse(new AwsException("InvalidArgument",
@@ -122,6 +122,18 @@ class S3MultipartServiceTest {
assertTrue(uploads.isEmpty());
}
@Test
void completeMultipartUploadVersioned() {
s3Service.putBucketVersioning("test-bucket", "Enabled");
MultipartUpload upload = s3Service.initiateMultipartUpload("test-bucket", "versioned.bin", "text/plain");
s3Service.uploadPart("test-bucket", "versioned.bin", upload.getUploadId(), 1, "data".getBytes());
S3Object result = s3Service.completeMultipartUpload("test-bucket", "versioned.bin",
upload.getUploadId(), List.of(1));
assertNotNull(result.getVersionId(), "Versioned bucket should produce a versionId");
}
@Test
void completeMultipartUploadCleansUp() {
MultipartUpload upload = s3Service.initiateMultipartUpload("test-bucket", "file.bin", null);