-
Notifications
You must be signed in to change notification settings - Fork 866
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 putObject via RequestBody.fromContentProvider yields an object with 0 bytes #5824
Comments
Hi @tarehart, Thank you for reporting the issue. I am able to reproduce the behaviour you mentioned. Looks specifically related to using Minimal reproducible code sample: public class Main {
public static void main(String[] args) throws MalformedURLException {
final var bucket = "****";
final var key = "regression.json";
final var url = new URL(
"https://raw.githubusercontent.com/aws/aws-sdk-java-v2/ad35231f768e1bb68e6f77cb29f69d1a7278931e/.changes/next-release/feature-AmazonS3-c101d4d.json"
);
var s3Client = S3Client.builder()
.region(Region.US_EAST_1)
.build();
try (var stream = url.openStream()) {
s3Client.putObject(
PutObjectRequest.builder().bucket(bucket).key(key).build(),
RequestBody.fromContentProvider(() -> stream, "application/json")
);
} catch (IOException e) {
throw new RuntimeException(e);
}
var length = s3Client.headObject(
HeadObjectRequest.builder().bucket(bucket).key(key).build()
).contentLength();
System.out.println(length); // prints 0
}
} From Java SDK We are looking into this issue further. Regards, |
Hi @tarehart, It looks like the implementation of ContentStreamProvider in your sample code does not satisfy its API contract. Per the interface's documentation [1], the result of Use
|
This issue is now closed. Comments on closed issues are hard for our team to see. |
Describe the bug
S3 putObject via RequestBody.fromContentProvider yields an object with 0 bytes. The operation completes as though it were successful, which increases the harm of this bug since there's potential for undetected data loss.
I believe this is related to #5801. The problem goes away when I set the environment variable
AWS_REQUEST_CHECKSUM_CALCULATION=WHEN_REQUIRED
.This started with 2.30.0.
Regression Issue
Expected Behavior
S3 putObject via RequestBody.fromContentProvider uploads all content from the input stream, yielding an object with non-zero size in the S3 bucket.
Current Behavior
The object in S3 has zero bytes, despite the operation reporting success.
Reproduction Steps
Possible Solution
No response
Additional Information/Context
No response
AWS Java SDK version used
2.30.1
JDK version used
openjdk version "17.0.13"
Operating System and version
MacOS 15.1.1
The text was updated successfully, but these errors were encountered: