fix(s3): Ensure tags are added on multipart s3 uploads. (#2151)

This commit is contained in:
floverfelt authored and GitHub committed 2026-08-07 16:09:18 -04:00
1 parent e0aab2e27d
commit f6faf0ffe5
5 files changed
+105 -2

No files matched your search

@@ -1164,7 +1164,8 @@ public class S3Controller {
httpHeaders.getHeaderString("x-amz-server-side-encryption-customer-algorithm"),
httpHeaders.getHeaderString("x-amz-server-side-encryption-customer-key"),
httpHeaders.getHeaderString("x-amz-server-side-encryption-customer-key-MD5"),
getChecksumAlgorithm(httpHeaders));
getChecksumAlgorithm(httpHeaders),
parseInlineTaggingHeader(httpHeaders.getHeaderString("x-amz-tagging")));
String xml = new XmlBuilder()
.raw("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
.start("InitiateMultipartUploadResult", AwsNamespaces.S3)
@@ -1343,6 +1343,16 @@ public class S3Service implements Resettable {
String contentDisposition, String serverSideEncryption, String acl,
String sseCustomerAlgorithm, String sseCustomerKey, String sseCustomerKeyMd5,
String checksumAlgorithm) {
return initiateMultipartUpload(bucket, key, contentType, metadata, storageClass, contentDisposition,
serverSideEncryption, acl, sseCustomerAlgorithm, sseCustomerKey, sseCustomerKeyMd5,
checksumAlgorithm, null);
}
public MultipartUpload initiateMultipartUpload(String bucket, String key, String contentType,
Map<String, String> metadata, String storageClass,
String contentDisposition, String serverSideEncryption, String acl,
String sseCustomerAlgorithm, String sseCustomerKey, String sseCustomerKeyMd5,
String checksumAlgorithm, Map<String, String> tagging) {
ensureBucketExists(bucket);
if (acl != null && !acl.isBlank()) {
cannedObjectAclXml(acl);
@@ -1363,6 +1373,9 @@ public class S3Service implements Resettable {
}
upload.setAcl(acl);
upload.setChecksumAlgorithm(validateAndNormalizeChecksumAlgorithm(checksumAlgorithm));
if (tagging != null && !tagging.isEmpty()) {
upload.setTagging(new HashMap<>(tagging));
}
if (inMemory) {
memoryMultipartStore.put(upload.getUploadId(), new ConcurrentHashMap<>());
@@ -1494,7 +1507,8 @@ public class S3Service implements Resettable {
.withStorageClass(upload.getStorageClass())
.withContentDisposition(upload.getContentDisposition())
.withServerSideEncryption(upload.getServerSideEncryption())
.withAcl(upload.getAcl()));
.withAcl(upload.getAcl())
.withTagging(upload.getTagging()));
if (upload.getSseCustomerAlgorithm() != null) {
object.setSseCustomerAlgorithm(upload.getSseCustomerAlgorithm());
object.setSseCustomerKeyMd5(upload.getSseCustomerKeyMd5());
@@ -23,6 +23,7 @@ public class MultipartUpload {
private String acl;
private String checksumAlgorithm;
private Map<String, String> metadata;
private Map<String, String> tagging;
private Instant initiated;
private final Map<Integer, Part> parts = new ConcurrentHashMap<>();
@@ -77,6 +78,9 @@ public class MultipartUpload {
public Map<String, String> getMetadata() { return metadata; }
public void setMetadata(Map<String, String> metadata) { this.metadata = metadata; }
public Map<String, String> getTagging() { return tagging; }
public void setTagging(Map<String, String> tagging) { this.tagging = tagging; }
public Instant getInitiated() { return initiated; }
public void setInitiated(Instant initiated) { this.initiated = initiated; }