I have used Java SDK and try to download Folder using GetObjectRequest class, but it is possible to download my folder incuding its subFolder and all files to download ?
I have used Java SDK and try to download Folder using GetObjectRequest class, but it is possible to download my folder incuding its subFolder and all files to download ?
Here's the code to download a whole bucket (somewhat tested):
import com.amazonaws.AmazonServiceException;
import aws.example.s3.XferMgrProgress;
import com.amazonaws.services.s3.transfer.TransferManager;
import com.amazonaws.services.s3.transfer.TransferManagerBuilder;
import com.amazonaws.services.s3.transfer.MultipleFileDownload;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import java.io.*;
import com.amazonaws.auth.PropertiesFileCredentialsProvider;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.AmazonClientException;
public class S3DownloadApp {
public static void main(String [] args){
AWSCredentials credentials = null;
try {
credentials = new PropertiesFileCredentialsProvider("keys.props").getCredentials();
} catch (Exception e) {
throw new AmazonClientException(
"Cannot load the credentials from the credential profiles file. " , e);
}
TransferManager xfer_mgr = TransferManagerBuilder.standard().withS3Client(AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(credentials)).withRegion("us-west-2").build()).build();//TransferManagerBuilder.standard().build();
try {
MultipleFileDownload xfer = xfer_mgr.downloadDirectory(
"bucketName", null, new File("/Users/admin/Desktop/downloadFolder"));
XferMgrProgress.showTransferProgress(xfer);
XferMgrProgress.waitForCompletion(xfer);
} catch (AmazonServiceException e) {
System.err.println(e.getErrorMessage());
System.exit(1);
}
}
}