What\'s the fastest way to write an S3 object (of which I have the key) to a file? I\'m using Java.
From AWS SDK for Java v2 released in 2017, you can just specify a Path
for writing to the file.
s3.getObject(GetObjectRequest.builder().bucket(bucket).key(key).build(),
ResponseTransformer.toFile(Paths.get("multiPartKey")));
https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/examples-s3-objects.html#download-object
If you need a File
, you can use toFile
method.
Path path = Paths.get("file.txt");
s3.getObject(GetObjectRequest.builder().bucket(bucket).key(key).build(),
path);
File file = path.toFile();