Skip to content

PutObject with streaming results empty Content-Encoding #729

@trung

Description

@trung

Describe the bug

As described in aws/aws-sdk-java-v2#4642

When using default S3 Async Client, then the issue is no longer there.

Expected Behavior

No Content-Encoding metadata

Current Behavior

Content-Encoding has empty value

Reproduction Steps

// using CRT
S3AsyncClient s3AsyncClient = S3AsyncClient.crtBuilder()
        .region(awsRegion)
        .credentialsProvider(awsCredentialsProvider)
        .build();

// not using CRT
// S3AsyncClient.builder()
//        .region(awsRegion)
//        .credentialsProvider(awsCredentialsProvider)
//        .build();

Path f = Paths.get("test.pdf");
Flux<ByteBuffer> fileFlux = Flux.using(
    () -> new FileReader(f.toFile()),
    reader -> Flux.fromStream(new BufferedReader(reader).lines()).map(s -> ByteBuffer.wrap(s.getBytes(
        StandardCharsets.UTF_8))),
    reader -> {
      try {
        reader.close();
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    }
);

final CompletableFuture<PutObjectResponse> s3Future =
        s3AsyncClient.putObject(
            PutObjectRequest.builder()
                .bucket("mybucket")
                .key("test.pdf")
                .contentLength(Files.size(f))
                .contentType(MediaType.APPLICATION_PDF_VALUE)
                .build(),
            AsyncRequestBody.fromPublisher(fileFlux));

test.pdf has Content-Encoding with empty value.
image

While if using non CRT S3 Async Client, test.pdf won't have Content-Encoding
image

Possible Solution

No response

Additional Information/Context

aws/aws-sdk-java-v2#4642

aws-crt-java version used

0.28.10

Java version used

17

Operating System and version

MacOS 14.1.1 (23B81)

Metadata

Metadata

Assignees

No one assigned

    Labels

    CRT/SDKbugThis issue is a bug.closed-for-stalenessp2This is a standard priority issueresponse-requestedWaiting on additional info and feedback. Will move to 'closing-soon' in 7 days.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions