0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AWS S3上にあるファイルのダウンロード

Posted at
// Groovy Version: 2.4.11 JVM: 1.8.0_144 Vendor: Oracle Corporation OS: Mac OS X
@Grab('com.amazonaws:aws-java-sdk-s3:1.11.184')
import com.amazonaws.regions.Regions
import com.amazonaws.services.s3.AmazonS3
import com.amazonaws.services.s3.AmazonS3ClientBuilder

import java.nio.file.Files
import java.nio.file.StandardCopyOption



AmazonS3 s3Client = AmazonS3ClientBuilder.standard()
        .withRegion(Regions.AP_NORTHEAST_1)
        .build()

def bucketName = 'your-bucket-name'
def key = 'some/s3/object/key'

def content = s3Client.getObject(bucketName, key).getObjectContent()
def file = new File('/path/to/download/dir/filename')
Files.copy(content, file.toPath(), StandardCopyOption.REPLACE_EXISTING)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?