I want to download a directory from my s3.
When I need a file, the s3 management console (aws web console) allows me to download it, but when a directory, I have to use aws-cli, like:
我想从我的s3下载一个目录。当我需要一个文件时,s3管理控制台(aws web控制台)允许我下载它,但是当一个目录时,我必须使用aws-cli,如:
$ aws s3 cp s3://mybucket/mydirectory/ . --recursive
My question is: Is there any way to get the s3 uri (s3://mybucket/mydirectory/
) from s3 management console?
It's URL is available, but it is slightly different from s3 URI required by aws-cli. I could not find any menu to get the uri.
我的问题是:有没有办法从s3管理控制台获取s3 uri(s3:// mybucket / mydirectory /)?它的URL可用,但它与aws-cli所需的s3 URI略有不同。我找不到任何菜单来获取uri。
Thank you in advance!
先谢谢你!
2 个解决方案
#1
21
No, it is not displayed in the console. However, it is simply:
不,它不会显示在控制台中。但是,它很简单:
s3://<bucket-name>/<key>
Directories are actually part of the key
. For example, foo.jpg
stored in an images
directory will actually have a key (filename) of images/foo.jpg
.
目录实际上是关键的一部分。例如,存储在images目录中的foo.jpg实际上将具有images / foo.jpg的键(filename)。
#2
2
(self-answer)
(自答案)
Because it seems there was no such way, I have created one:
因为似乎没有这样的方式,我创造了一个:
pip install aws-s3-url2uri
And command aws_s3_url2uri
will be available after installation.
安装后命令aws_s3_url2uri将可用。
This command internally converts the web console URLs to S3 URIs, so works with URLs and URIs and local paths:
此命令在内部将Web控制台URL转换为S3 URI,因此可以使用URL和URI以及本地路径:
aws_s3_url2uri ls "https://console.aws.amazon.com/s3/home?region=<regionname>#&bucket=mybucket&prefix=mydir/mydir2/"
calls
电话
aws s3 ls s3://mybucket/mydir/mydir2/
internally.
内部。
#1
21
No, it is not displayed in the console. However, it is simply:
不,它不会显示在控制台中。但是,它很简单:
s3://<bucket-name>/<key>
Directories are actually part of the key
. For example, foo.jpg
stored in an images
directory will actually have a key (filename) of images/foo.jpg
.
目录实际上是关键的一部分。例如,存储在images目录中的foo.jpg实际上将具有images / foo.jpg的键(filename)。
#2
2
(self-answer)
(自答案)
Because it seems there was no such way, I have created one:
因为似乎没有这样的方式,我创造了一个:
pip install aws-s3-url2uri
And command aws_s3_url2uri
will be available after installation.
安装后命令aws_s3_url2uri将可用。
This command internally converts the web console URLs to S3 URIs, so works with URLs and URIs and local paths:
此命令在内部将Web控制台URL转换为S3 URI,因此可以使用URL和URI以及本地路径:
aws_s3_url2uri ls "https://console.aws.amazon.com/s3/home?region=<regionname>#&bucket=mybucket&prefix=mydir/mydir2/"
calls
电话
aws s3 ls s3://mybucket/mydir/mydir2/
internally.
内部。