我注意到似乎没有从AWS管理控制台下载整个s3桶的选项。
有什么简单的方法可以把所有东西都装进我的桶里吗?我正在考虑使根文件夹公共,使用wget抓取它,然后再次使它私有,但我不知道是否有更简单的方法。
我注意到似乎没有从AWS管理控制台下载整个s3桶的选项。
有什么简单的方法可以把所有东西都装进我的桶里吗?我正在考虑使根文件夹公共,使用wget抓取它,然后再次使它私有,但我不知道是否有更简单的方法。
当前回答
如果您只想从AWS下载桶,请首先在您的计算机中安装AWS CLI。在终端更改目录到你想下载的文件,并运行这个命令。
aws s3 sync s3://bucket-name .
如果你也想同步本地和s3目录(如果你在本地文件夹中添加了一些文件),运行这个命令:
aws s3 sync . s3://bucket-name
其他回答
您可以使用这个AWS cli命令将整个S3桶内容下载到本地文件夹
aws s3 sync s3://your-bucket-name "Local Folder Path"
如果你看到这样的错误
fatal error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)
——no-verify-ssl(布尔)
默认情况下,AWS CLI与AWS服务通信时使用SSL。对于每个SSL连接,AWS CLI将验证SSL证书。此选项将覆盖验证SSL证书的默认行为。 参考
使用命令——no-verify-ssl来使用这个标记
aws s3 sync s3://your-bucket-name "Local Folder Path" --no-verify-ssl
这里有一些东西可以下载所有桶,列出它们,列出它们的内容。
//connection string
private static void dBConnection() {
app.setAwsCredentials(CONST.getAccessKey(), CONST.getSecretKey());
conn = new AmazonS3Client(app.getAwsCredentials());
app.setListOfBuckets(conn.listBuckets());
System.out.println(CONST.getConnectionSuccessfullMessage());
}
private static void downloadBucket() {
do {
for (S3ObjectSummary objectSummary : app.getS3Object().getObjectSummaries()) {
app.setBucketKey(objectSummary.getKey());
app.setBucketName(objectSummary.getBucketName());
if(objectSummary.getKey().contains(CONST.getDesiredKey())){
//DOWNLOAD
try
{
s3Client = new AmazonS3Client(new ProfileCredentialsProvider());
s3Client.getObject(
new GetObjectRequest(app.getBucketName(),app.getBucketKey()),
new File(app.getDownloadedBucket())
);
} catch (IOException e) {
e.printStackTrace();
}
do
{
if(app.getBackUpExist() == true){
System.out.println("Converting back up file");
app.setCurrentPacsId(objectSummary.getKey());
passIn = app.getDataBaseFile();
CONVERT= new DataConversion(passIn);
System.out.println(CONST.getFileDownloadedMessage());
}
}
while(app.getObjectExist()==true);
if(app.getObjectExist()== false)
{
app.setNoObjectFound(true);
}
}
}
app.setS3Object(conn.listNextBatchOfObjects(app.getS3Object()));
}
while (app.getS3Object().isTruncated());
}
/---------------------------- 扩展方法 -------------------------------------/
//Unzip bucket after download
public static void unzipBucket() throws IOException {
unzip = new UnZipBuckets();
unzip.unZipIt(app.getDownloadedBucket());
System.out.println(CONST.getFileUnzippedMessage());
}
//list all S3 buckets
public static void listAllBuckets(){
for (Bucket bucket : app.getListOfBuckets()) {
String bucketName = bucket.getName();
System.out.println(bucketName + "\t" + StringUtils.fromDate(bucket.getCreationDate()));
}
}
//Get the contents from the auto back up bucket
public static void listAllBucketContents(){
do {
for (S3ObjectSummary objectSummary : app.getS3Object().getObjectSummaries()) {
if(objectSummary.getKey().contains(CONST.getDesiredKey())){
System.out.println(objectSummary.getKey() + "\t" + objectSummary.getSize() + "\t" + StringUtils.fromDate(objectSummary.getLastModified()));
app.setBackUpCount(app.getBackUpCount() + 1);
}
}
app.setS3Object(conn.listNextBatchOfObjects(app.getS3Object()));
}
while (app.getS3Object().isTruncated());
System.out.println("There are a total of : " + app.getBackUpCount() + " buckets.");
}
}
如果您使用带有S3Fox的Firefox,它确实允许您选择所有文件(shift-选择第一个和最后一个),然后右键单击并下载所有文件。
我已经处理了500多个文件,没有任何问题。
您有许多选项可以做到这一点,但最好的是使用AWS CLI。
下面是一篇简介:
Download and install AWS CLI in your machine: Install the AWS CLI using the MSI Installer (Windows). Install the AWS CLI using the Bundled Installer for Linux, OS X, or Unix. Configure AWS CLI: Make sure you input valid access and secret keys, which you received when you created the account. Sync the S3 bucket using: aws s3 sync s3://yourbucket /local/path In the above command, replace the following fields: yourbucket >> your S3 bucket that you want to download. /local/path >> path in your local system where you want to download all the files.
如果您使用Visual Studio,请下载“AWS Toolkit for Visual Studio”。
安装完成后,进入Visual Studio - AWS Explorer - S3 -您的存储桶-双击
在窗口中,您将能够选择所有文件。右键单击并下载文件。