Amazon S3控制台:一次下载多个文件

时间:2017-01-20 13:27:43

标签: amazon-s3 web-console

当我登录 S3控制台时,我无法下载多个所选文件(只有选择了一个文件时,WebUI才允许下载):

https://console.aws.amazon.com/s3

这可以在用户策略中更改,还是亚马逊的限制?

17 个答案:

答案 0 :(得分:28)

通过Web用户界面无法实现。 但是,如果您安装AWS CLI,这是一项非常简单的任务。 您可以在AWS Command Line Interface

中查看安装的安装和配置步骤

之后你去cmd。 输入:

aws s3 cp "S3 PATH" "LOCAL PATH" --recursive

请勿使用双引号。 这会将给定S3路径中的所有文件复制到给定的本地路径。

答案 1 :(得分:14)

如果您使用AWS CLI,则可以使用exclude以及--include--recursive标记来完成此操作

aws s3 cp s3://path/to/bucket/ . --recursive --exclude "*" --include "things_you_want"

例如

--exclude "*" --include "*.txt"

将下载扩展名为.txt的所有文件。更多详情 - https://docs.aws.amazon.com/cli/latest/reference/s3/

答案 2 :(得分:6)

选择一堆文件并单击“操作”->“打开”会在浏览器选项卡中打开每个文件,然后它们立即开始下载(一次6个)。

Screenshot

答案 3 :(得分:2)

我认为这是AWS控制台网络界面的一个限制,我已经尝试(并且失败)自己这样做。

或者,也许使用第三方S3浏览器客户端,例如http://s3browser.com/

答案 4 :(得分:2)

S3 服务对同时下载没有任何有意义的限制(一次可以轻松下载几百个),并且没有与此相关的策略设置...但是S3 控制台只允许您一次选择一个文件进行下载。

下载开始后,您可以启动另一个和另一个,只要您的浏览器允许您同时尝试。

答案 5 :(得分:1)

使用 AWS CLI,我使用“&”在后台运行所有下载,然后等待所有 pid 完成。这是惊人的快。显然,“aws s3 cp”知道限制并发连接数,因为它一次只运行 100 个。

aws --profile $awsProfile s3 cp "$s3path" "$tofile" &
pids[${npids}]=$! ## save the spawned pid
let "npids=npids+1"

关注

echo "waiting on $npids downloads"
for pid in ${pids[*]}; do
    echo $pid
    wait $pid
done

我在大约一分钟内下载了 1500 多个文件(72,000 字节)

答案 6 :(得分:1)

我已经完成了,通过使用aws cli(即example.sh)创建shell脚本

#!/bin/bash
aws s3 cp s3://s3-bucket-path/example1.pdf LocalPath/Download/example1.pdf
aws s3 cp s3://s3-bucket-path/example2.pdf LocalPath/Download/example2.pdf

授予example.sh的可执行权限(即sudo chmod 777 example.sh)

然后运行您的Shell脚本 ./ example.sh

答案 7 :(得分:1)

此外,如果您正在运行Windows(tm),则WinSCP现在允许拖放多个文件。包括子文件夹。

许多企业工作站将安装WinSCP,以通过SSH编辑服务器上的文件。

我没有隶属关系,我只是认为这确实值得做。

答案 8 :(得分:1)

您还可以在单​​个命令中多次使用--include "filename",每次都在双引号中包含不同的文件名,例如

aws s3 mycommand --include "file1" --include "file2"

这将节省您的时间,而不是重复执行一次一次下载一个文件的命令。

答案 9 :(得分:0)

如果您具有安装了AWS Explorer扩展的Visual Studio,则还可以浏览到Amazon S3(步骤1),选择存储桶(步骤2),然后选择所有要下载的文件(步骤3),然后右键单击全部下载(第4步)。

enter image description here

答案 10 :(得分:0)

在我的情况下,Aur无法正常运行,如果您正在寻找一种快速解决方案,仅使用浏览器下载文件夹中的所有文件,则可以尝试在开发控制台中输入以下代码段:

(function() {
    const rows = Array.from(document.querySelectorAll('.fix-width-table tbody tr'));
    const downloadButton = document.querySelector('[data-e2e-id="button-download"]');
    const timeBetweenClicks = 500;

    function downloadFiles(remaining) {
        if (!remaining.length) {
            return
        }

        const row = remaining[0];
        row.click();
        downloadButton.click();

        setTimeout(() => {
            downloadFiles(remaining.slice(1));
        }, timeBetweenClicks)
    }

    downloadFiles(rows)
}())

答案 11 :(得分:0)

我编写了一个简单的Shell脚本,以从AWS s3存储桶下的特定文件夹下载“不仅仅是”所有文件,还下载了每个文件的所有版本。在这里,您可能会发现它有用

# Script generates the version info file for all the 
# content under a particular bucket and then parses 
# the file to grab the versionId for each of the versions
# and finally generates a fully qualified http url for
# the different versioned files and use that to download 
# the content.

s3region="s3.ap-south-1.amazonaws.com"
bucket="your_bucket_name"
# note the location has no forward slash at beginning or at end
location="data/that/you/want/to/download"
# file names were like ABB-quarterly-results.csv, AVANTIFEED--quarterly-results.csv
fileNamePattern="-quarterly-results.csv"

# AWS CLI command to get version info
content="$(aws s3api list-object-versions --bucket $bucket --prefix "$location/")"
#save the file locally, if you want
echo "$content" >> version-info.json
versions=$(echo "$content" | grep -ir VersionId  | awk -F ":" '{gsub(/"/, "", $3);gsub(/,/, "", $3);gsub(/ /, "", $3);print $3 }')
for version in $versions
do
    echo ############### $fileId ###################
    #echo $version
    url="https://$s3region/$bucket/$location/$fileId$fileNamePattern?versionId=$version"
    echo $url
    content="$(curl -s "$url")"
    echo "$content" >> $fileId$fileNamePattern-$version.csv
    echo ############### $i ###################
done

答案 12 :(得分:0)

我通常要做的是将s3存储桶(与s3fs一起)安装在linux计算机中,并将所需的文件压缩为一个,然后从任何PC /浏览器中下载该文件。

# mount bucket in file system
/usr/bin/s3fs s3-bucket -o use_cache=/tmp -o allow_other -o uid=1000 -o mp_umask=002 -o multireq_max=5 /mnt/local-s3-bucket-mount

# zip files into one
cd /mnt/local-s3-bucket-mount
zip all-processed-files.zip *.jpg

答案 13 :(得分:0)

我认为下载或上传文件的最简单方法是使用 aws s3 sync 命令。您还可以使用它同时sync 两个 s3 存储桶。

aws s3 sync <LocalPath> <S3Uri> or <S3Uri> <LocalPath> or <S3Uri> <S3Uri>

# Download file(s)
aws s3 sync s3://<bucket_name>/<file_or_directory_path> .

# Upload file(s)
aws s3 sync . s3://<bucket_name>/<file_or_directory_path>

# Sync two buckets
aws s3 sync s3://<1st_s3_path> s3://<2nd_s3_path>

答案 14 :(得分:0)

您也可以使用Cyber​​Duck。它与S3搭配使用效果很好,您可以下载一个文件夹。

答案 15 :(得分:-1)

如果有人仍在寻找S3浏览器和下载器,我刚刚尝试了Fillezilla Pro(付费版本)。效果很好。

我使用通过IAM设置的访问密钥和私有密钥创建了到S3的连接。连接是即时的,所有文件夹和文件的下载都很快。

答案 16 :(得分:-1)

导入操作系统 导入boto3 导入json

s3 = boto3.resource('s3',aws_access_key_id =“ AKIAxxxxxxxxxxxxJWB”, aws_secret_access_key =“ LV0 + vsaxxxxxxxxxxxxxxxxxxxxxry0 / LjxZkN”) my_bucket = s3.Bucket('s3testing')

将文件下载到当前目录

对于my_bucket.objects.all()中的s3_object: #需要将s3_object.key拆分为路径和文件名,否则将给出未找到的错误文件。 路径,文件名= os.path.split(s3_object.key) my_bucket.download_file(s3_object.key,文件名)