-
Notifications
You must be signed in to change notification settings - Fork 836
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
AsyncRequestBody: ability to set content-type #5143
Comments
Providing content-type to PutObjectRequest (not the request body) should work fine, I believe. Can you share a repro code showing how you're making the upload? |
I do it like this: public CompletableFuture<PutObjectResponse> uploadContentAsync(ContentId contentId, AsyncRequestBody body) {
var requestBuilder = PutObjectRequest.builder()
.bucket(contentId.bucket())
.key(contentId.key()
.contentType(body.contentType()); // Use contentType from body here
return client.putObject(requestBuilder.build(), body);
} So, content-type can be set in My point here is: why do we need to add extra-argument It is far more obvious and easy to use single source-of-truth instead of always aware, which source is more thuth here... |
Understood, thank you for the code sample. Feature request acknowledged. Community note: please show your support by adding a 👍 reaction to the original issue to help us prioritize this request. |
…uestBody (#5234) * Allows users to configure contentType for BlockingInputStreamAsyncRequestBody (#5143) * Run new-change (#5143) * Add tests for BlockingInputStreamAsyncRequestBody (#5143) * Update tests --------- Co-authored-by: Kirill Chaykin <k.chaykin@metamodel.ru> Co-authored-by: hdavidh <hdavidh@amazon.com> Co-authored-by: David Ho <70000000+davidh44@users.noreply.github.com>
Feature was implemented in PR 5234 and merged to master |
This issue is now closed. Comments on closed issues are hard for our team to see. |
…uestBody (aws#5234) * Allows users to configure contentType for BlockingInputStreamAsyncRequestBody (aws#5143) * Run new-change (aws#5143) * Add tests for BlockingInputStreamAsyncRequestBody (aws#5143) * Update tests --------- Co-authored-by: Kirill Chaykin <k.chaykin@metamodel.ru> Co-authored-by: hdavidh <hdavidh@amazon.com> Co-authored-by: David Ho <70000000+davidh44@users.noreply.github.com>
Describe the feature
There is special
AsyncRequestBody
implementation for uploading content to S3 byInputStream
. It isBlockingInputStreamAsyncRequestBody
. This class is useful and simple, but it has no way to set custom content-type:contentType
method overriding (so, default implementation fromAsyncRequestBody
used instead. That implementation simply always returnsapplication/octet-stream
)Use Case
Any time I need to upload my existing
InputStream
, I want to use thisBlockingInputStreamAsyncRequestBody
. But, then my content type is differ fromapplication/octet-stream
(almost always), I need to have own copy-past implementation with my custom content-type...Proposed Solution
contentType
toBlockingInputStreamAsyncRequestBody
contentType
contentType
method to return corresponding fieldOther Information
No response
Acknowledgements
AWS Java SDK version used
2.25.37
JDK version used
java 17.0.6 2023-01-17 LTS Java(TM) SE Runtime Environment (build 17.0.6+9-LTS-190) Java HotSpot(TM) 64-Bit Server VM (build 17.0.6+9-LTS-190, mixed mode, sharing)
Operating System and version
Ubuntu 22.04.3 LTS
The text was updated successfully, but these errors were encountered: