Skip to content

Commit

Permalink
Do not apply ObjectMetadata#contentLength for UploadPartRequest. (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
Mobe91 committed Oct 2, 2024
1 parent 8020ef1 commit f5bb9a3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,6 @@ void apply(CreateMultipartUploadRequest.Builder builder) {
}

void apply(UploadPartRequest.Builder builder) {
if (contentLength != null) {
builder.contentLength(contentLength);
}
if (sseCustomerAlgorithm != null) {
builder.sseCustomerAlgorithm(sseCustomerAlgorithm);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import software.amazon.awssdk.services.s3.model.RequestPayer;
import software.amazon.awssdk.services.s3.model.ServerSideEncryption;
import software.amazon.awssdk.services.s3.model.StorageClass;
import software.amazon.awssdk.services.s3.model.UploadPartRequest;

/**
* Unit tests for {@link ObjectMetadata}.
Expand Down Expand Up @@ -78,4 +79,17 @@ void mapsEnumsToString() {
assertThat(result.checksumAlgorithm()).isEqualTo(ChecksumAlgorithm.CRC32);
}

@Test
void doesNotApplyContentLengthForPartUpload() {
long objectContentLength = 16L;
long partContentLength = 8L;
ObjectMetadata metadata = ObjectMetadata.builder().contentLength(objectContentLength).build();

UploadPartRequest.Builder builder = UploadPartRequest.builder().contentLength(partContentLength);
metadata.apply(builder);
UploadPartRequest result = builder.build();

assertThat(result.contentLength()).isEqualTo(partContentLength);
}

}

0 comments on commit f5bb9a3

Please sign in to comment.