amazon - AWS 之 S3存储桶介绍 / 安装配置AWS CLI

目录

1.AWS 官方文档

2.安装配置AWS CLI

3.AWS S3 CLI命令介绍

(1)aws s3 cli 所有命令关键字

(2)aws s3 cli命令详解


1.AWS 官方文档

AWS SDK for python (用boto3库)

https://boto3.amazonaws.com/v1/documentation/api/latest/index.html

AWS S3 SDK for python 

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html

AWS S3 CLI 文档

https://docs.aws.amazon.com/cli/latest/reference/s3/index.html

2.安装配置AWS CLI

使用pip安装 AWS CLI

pip install awscli --upgrade --user

配置AWS CLI

#key为公司key

$ aws configure

AWS Access Key ID [None]: AKIAUxxxxxxxxxxxxxxxxxxxxx

AWS Secret Access Key [None]: Jdwtexxxxxxxxxxxxxxxxx

Default region name [None]: cn-north-1

Default output format [None]:json

3.AWS S3 CLI命令介绍

(1)aws s3 cli 所有命令关键字

cp :将本地文件或S3对象复制到本地或S3中的另一个位置。

ls:在前缀或所有S3存储桶下列出S3对象和公共前缀。此命令将忽略--output和--no-paginate。

mb:创建一个S3存储桶。

mv:将本地文件或S3对象移动到本地或S3中的另一个位置。

presign:为Amazon S3对象生成一个预签名的URL。

rb:删除一个空的S3存储桶。该命令只能删除空桶。

rm:删除一个S3对象。

sync:同步目录和S3前缀。将新文件和更新文件从源目录递归复制到目标。如果文件夹包含一个或多个文件,则仅在目标文件夹中创建文件夹。

website:设置存储桶的网站配置。

(2)aws s3 cli命令详解

上传文件存储桶

aws s3 cp L2_P3.zip s3://temp-files

aws s3 cp L2_02.zip s3://gz-shared --profile george

aws s3 cp ./mws_manage_fba_inventory.zip s3://temp-files/ --profile cn

下载文件至本地

aws s3 cp s3://temp-files/Listing_20190712.tar.gz /home/ubuntu

列出了所有存储桶

aws s3 ls

列出存储桶中的所有对象和文件夹

aws s3 ls s3://bucket-name

列出bucket-name/ 中的对象 path

aws s3 ls s3://bucket-name/path/

删除一个桶

aws s3 rb s3://bucket-name

默认情况下,存储桶必须为空才能使操作成功。要删除非空存储桶,您需要包含该--force选项。

aws s3 rb s3://bucket-name --force

aws s3 cp s3://temp-files/res_amzseo_1001.zip /home/ubuntu

将文件或文件夹同步至s3

aws s3 sync html_0912 s3://seo-html-bucket/html/html_0912/ #若不存在html目录会创建一个

猜你喜欢

转载自blog.csdn.net/helunqu2017/article/details/115221349