-
Notifications
You must be signed in to change notification settings - Fork 864
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
S3: Content length error on put object request #5807
Comments
Hi @toon-borgers-hs, Thank you for reporting the issue. I am able to reproduce the exception with AWS S3 endpoint as well with version This looks related to Minimal reproducible code snippet public static void upload() {
var bucket = "<<bucketname";
var contentLength = 20 * 1024 * 1024;
var random = new Random();
var randomData = new byte[contentLength];
random.nextBytes(randomData);
var client =
S3AsyncClient.builder()
.region(Region.of("us-east-1"))
.multipartEnabled(true)
.build();
var transferManager = S3TransferManager.builder().s3Client(client).build();
ExecutorService executor = Executors.newSingleThreadExecutor();
try (var stream = new ByteArrayInputStream(randomData)) {
var uploadRequest = UploadRequest.builder()
.putObjectRequest(
b ->
b.bucket(bucket)
.key("key")
.contentType("text/plain")
.contentLength((long) contentLength))
.requestBody(
AsyncRequestBody.fromInputStream(
b ->
b.inputStream(stream)
.contentLength((long) contentLength)
.executor(executor)))
.build();
transferManager
.upload(uploadRequest)
.completionFuture()
.join();
} catch (IOException e) {
throw new RuntimeException(e);
}
finally {
executor.shutdown();
try {
executor.awaitTermination(1, TimeUnit.MINUTES);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
transferManager.close();
}
} We are looking further into this. Regards, |
Hi @toon-borgers-hs we released a fix in |
This issue is now closed. Comments on closed issues are hard for our team to see. |
Describe the bug
Since version
2.30.1
, I'm getting an error when I do a put request using multipart upload and the transfer manager. If I pass thecontentLength
parameter in the put object request, I get an error likeRequest content was only 4196352 bytes, but the specified content-length was 20981796 bytes.
I don't get this if I leave the content length parameter off of the put object request.
I'm also setting it on the request body, but there it's not causing an issue.
Regression Issue
Expected Behavior
The upload should still work as before 2.30.1
Current Behavior
I get an error:
Reproduction Steps
Possible Solution
No response
Additional Information/Context
No response
AWS Java SDK version used
2.30.1
JDK version used
openjdk 23 2024-09-17 OpenJDK Runtime Environment (build 23+37-2369) OpenJDK 64-Bit Server VM (build 23+37-2369, mixed mode, sharing)
Operating System and version
MacOS 15.0.1 (24A348)
The text was updated successfully, but these errors were encountered: