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

S3: GetObjectRequest toFile option to override file #2300

Open
1 task done
mina-asham opened this issue Feb 26, 2021 · 2 comments · May be fixed by #3772
Open
1 task done

S3: GetObjectRequest toFile option to override file #2300

mina-asham opened this issue Feb 26, 2021 · 2 comments · May be fixed by #3772
Labels
feature-request A feature should be added or improved. p1 This is a high priority issue service:s3

Comments

@mina-asham
Copy link

mina-asham commented Feb 26, 2021

Migrating from SDK V1 to V2 we hit an issue where do something like this (pseudo-code):

Path temp = Files.createTempFile(...);
s3.getObject(bucket, key, temp);
// use temp file

This allows us to download a temp file, validate it and if we are happy flip it to the actual path overriding the existing previous file.

This works on V1 because: because it just opens an outputstream which by default overwrites (here)
but doesn't work on V2 because we are not passing any options to Files.copy (here)

Describe the Feature

Allow the use of S3 client to download an object to an existing file by overwriting it

Is your Feature Request related to a problem?

See general summary

Proposed Solution

  • Suggestion 1 (preferred): adding an overload with a boolean overwrite for this toFile method here that can be passed to the Files.copy call as StandardCopyOption.REPLACE_EXISTING (only option allowed when using Files.copy with an input stream)
  • Suggestion 2 (less preferred because it's ugly but works): Add another method in ResponseTransformer, e.g. ResponseTransformer.toFileOverwrite
  • Suggestion 3 (not preferred because it's a breaking change): Change the default behaviour and hardcode StandardCopyOption.REPLACE_EXISTING

Describe alternatives you've considered

See suggestion 2/3 in proposed solution

Additional Context

  • I may be able to implement this feature request

Your Environment

  • AWS Java SDK version used: N/A
  • JDK version used: N/A
  • Operating System and version: N/A
@mina-asham mina-asham added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Feb 26, 2021
@debora-ito
Copy link
Member

Thank you for reaching out @mina-asham.
We agree that should be a feature parity with v1 in this case, marking this as a feature request.

@debora-ito debora-ito removed the needs-triage This issue or PR still needs to be triaged. label Mar 3, 2021
mina-asham added a commit to mina-asham/aws-sdk-java-v2 that referenced this issue Jul 14, 2021
mina-asham added a commit to mina-asham/aws-sdk-java-v2 that referenced this issue Jul 14, 2021
@mina-asham
Copy link
Author

I have submitted a PR for the suggested fix here: #2595, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. p1 This is a high priority issue service:s3
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants