Open
Description
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 thistoFile
method here that can be passed to theFiles.copy
call asStandardCopyOption.REPLACE_EXISTING
(only option allowed when usingFiles.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
Activity