Skip to content

Conversation

@joviegas
Copy link
Contributor

@joviegas joviegas commented Jan 23, 2026

Motivation and Context

When uploading files using S3AsyncClient with multipartEnabled(true), the content-type from AsyncRequestBody (e.g., text/html for .html files) was ignored. Instead, multipart uploads always used the default binary/octet-stream. This caused files to be stored with incorrect content-type in S3. Fixes #6607.

Modifications

  • Added content-type enrichment in UploadObjectHelper.uploadObject() to propagate content-type from AsyncRequestBody to PutObjectRequest
    before multipart upload.

Before this fix:

  • Single-part uploads correctly used the content-type from AsyncRequestBody (e.g., text/html for .html files)
  • Multipart uploads ignored AsyncRequestBody.contentType() and always defaulted to binary/octet-stream

After this fix:

  • Both single-part and multipart uploads now consistently use the content-type from AsyncRequestBody

Testing

  • Added unit tests in UploadObjectHelperTest and UploadWithUnknownContentLengthHelperTest
  • Added WireMock functional tests in S3MultipartClientContentTypeTest verifying content-type propagation for both single-part and
    multipart uploads
  • All existing S3 and Transfer Manager tests pass

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

License

  • I confirm that this pull request can be released under the Apache 2 license

@joviegas joviegas requested a review from a team as a code owner January 23, 2026 01:37
@joviegas joviegas force-pushed the joviegas/multipart_content_type branch from f68108d to dc7c27c Compare January 23, 2026 01:51
@joviegas joviegas force-pushed the joviegas/multipart_content_type branch from ca92239 to e26c767 Compare January 23, 2026 22:21
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MultipartS3AsyncClient infers content type for single-part uploads but not multi-part uploads

1 participant