Skip to content
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

Migration Tool: PutObjectRequest File/InputStream transform #5942

Merged
merged 4 commits into from
Mar 18, 2025

Conversation

davidh44
Copy link
Contributor

@davidh44 davidh44 commented Mar 7, 2025

Motivation and Context

Modifications

Refactored common code to S3TransformUtils (separate commit)

Transforms for PutObjectRequest:

  • Constructors:
    PutObjectRequest(String bucketName, String key, File file)
    PutObjectRequest(String bucketName, String key, String redirectLocation)
  • Setters:
    withFile setFile
    withInputStream setInputStream
    withRequesterPays
    withBucketName
    withCannedAcl

Transforms for AmazonS3.putObject(PutObjectRequest)

  • If no payload set: RequestBody.empty()
  • If File set: RequestBody.fromFile()
  • If InputStream set:
    • If Content-Length provided: RequestBody.fromInputStream(inputStream, contentLength)
    • Else: RequestBody.fromContentProvider(() -> inputStream, "binary/octet-stream") (comment will be added to tell users to specify length, and warn stream will be buffered)

Transforms for TransferManager.upload(PutObjectRequest)

  • If no payload set: tm.upload(UploadRequest...requestBody(AsyncRequestBody.empty())
  • If File set: tm.uploadFile(UploadFileRequest...source(file)
  • If InputStream set:
    • If Content-Length not provided, will default to -1
    • Undefined variable will be passed to ExecutorService arg, transformed code will fail at runtime (comment will be added to tell users to set):
    • tm.upload(UploadRequest...requestBody(AsyncRequestBody.fromInputStream(inputStream, contentLength, newExecutorServiceVariableToDefine)

TODO in follow up PRs:

  1. transform ObjectMetadata and pass on Content-Length to RequestBody.fromInputStream() / AsyncRequestBody.fromInputStream()
  2. remaining PutObjectRequest setters

Testing

added end to end tests

@davidh44 davidh44 requested a review from a team as a code owner March 7, 2025 22:59
@davidh44 davidh44 enabled auto-merge March 17, 2025 21:41
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
5.2% Coverage on New Code (required ≥ 80%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@davidh44 davidh44 added this pull request to the merge queue Mar 17, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Mar 17, 2025
@davidh44 davidh44 added this pull request to the merge queue Mar 17, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 18, 2025
@davidh44 davidh44 added this pull request to the merge queue Mar 18, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Mar 18, 2025
@davidh44 davidh44 added this pull request to the merge queue Mar 18, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Mar 18, 2025
@davidh44 davidh44 added this pull request to the merge queue Mar 18, 2025
Merged via the queue into master with commit f87c076 Mar 18, 2025
16 of 17 checks passed
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.

3 participants