当我登录到我的S3 控制台时,我无法下载多个选定的文件(WebUI 仅在选择一个文件时才允许下载):
https://console.aws.amazon.com/s3
这是可以在用户政策中更改的内容还是亚马逊的限制?
当我登录到我的S3 控制台时,我无法下载多个选定的文件(WebUI 仅在选择一个文件时才允许下载):
https://console.aws.amazon.com/s3
这是可以在用户政策中更改的内容还是亚马逊的限制?
无法通过 AWS 控制台 Web 用户界面进行操作。但是,如果您安装 AWS CLI,这是一项非常简单的任务。您可以查看在AWS 命令行界面中安装的安装和配置步骤
之后,您转到命令行:
aws s3 cp --recursive s3://<bucket>/<folder> <local_folder>
这会将所有文件从给定的 S3 路径复制到给定的本地路径。
如果您使用 AWS CLI,则可以使用exclude
with--include
和--recursive
flags 来完成此操作
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/
我相信这是 AWS 控制台 Web 界面的限制,我自己尝试过(但失败了)。
或者,也许使用第三方 S3 浏览器客户端,例如http://s3browser.com/
S3服务对同时下载没有有意义的限制(一次可以轻松下载数百次),并且没有与此相关的策略设置......但是 S3控制台只允许您一次选择一个文件进行下载。
下载开始后,您可以启动一个又一个,只要您的浏览器允许您同时尝试即可。
此外,如果您正在运行 Windows(tm),WinSCP 现在允许拖放多个文件的选择。包括子文件夹。
许多企业工作站将安装 WinSCP,以便通过 SSH 编辑服务器上的文件。
我不隶属,我只是认为这真的很值得做。
我编写了一个简单的 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
我已经完成了,通过使用 aws cli 创建 shell 脚本(即:example.sh)
#!/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
使用 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 字节)
如果有人还在寻找 S3 浏览器和下载器,我刚刚尝试了 Fillezilla Pro(它是付费版本)。效果很好。
我使用通过 IAM 设置的访问密钥和密钥创建了与 S3 的连接。连接是即时的,所有文件夹和文件的下载速度很快。
Also you could use the --include "filename"
many times in a single command with each time including a different filename within the double quotes, e.g.
aws s3 mycommand --include "file1" --include "file2"
It will save your time rather than repeating the command to download one file at a time.
在我的情况下,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)
}())
我通常做的是将 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
您也可以使用 CyberDuck。它适用于 S3,您可以下载一个文件夹。
我认为下载或上传文件的最简单方法是使用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>
import os
import boto3
import json
s3 = boto3.resource('s3', aws_access_key_id="AKIAxxxxxxxxxxxxJWB",
aws_secret_access_key="LV0+vsaxxxxxxxxxxxxxxxxxxxxxry0/LjxZkN")
my_bucket = s3.Bucket('s3testing')
# download file into current directory
for s3_object in my_bucket.objects.all():
# Need to split s3_object.key into path and file name, else it will give error file not found.
path, filename = os.path.split(s3_object.key)
my_bucket.download_file(s3_object.key, filename)