arpit joshi
arpit joshi

Reputation: 2144

How can we download multiple files without folder from S3 bucket using Java SDK

Is there a way where I can download multiple files from s3 using java sdk .I don't want to download subfodlers,only files present in the specified folder .

Let's say I have a bucket

BucketName: 
       Mlearn 

Keys : 
       staticConfig/cities.csv 
       staticConfig/ABC.csv 
       staticConfig/pwd.csv 
       staticConfig/Check/xyz.csv 
       staticConfig/Check/pqr.csv 

I only need to download cities.csv,ABC.csv and pwd.csv nothing should be downloaded in the subfolder Check .

I tried to use the below api

TransferManager tx=new TransferManager(getS3Client());

MultipleFileDownload multi=tx.downloadDirectory("Mlearn", "staticConfig", "D:/temp");

This downloads entire subfolder Check also .

Can some one please advise .

Well though I can list and download one by one file ,it's not going to be efficient .

When I did a calculation of downloading one by one file v/s downloading using TransFerManager ,the time taken by TXManager was 1.6 seconds while one by one was 2.9 Seconds.

Hence want to restrict the use of manual download of file one by one .

Upvotes: 1

Views: 2665

Answers (1)

ketan vijayvargiya
ketan vijayvargiya

Reputation: 5659

TransferManager doesn't directly support what you want. While downloading one by one, you can run all the downloads in parallel (for e.g., by using an ExecutorService) to decrease latency.

Upvotes: 1

Related Questions