Post

AWS S3 CLI

AWS S3 CLI

List all buckets

1
2
[~]$ aws s3 ls
2023-05-16 10:53:26 exampro-202305

List all folders and objects in bucket

1
2
[~]$ aws s3 ls exampro-202305
                           PRE enterprise/

List all folders and objects in folder

1
2
3
4
[~]$ aws s3 ls exampro-202305/enterprise/
2023-05-16 12:13:19          0 
2023-05-16 12:44:06     210155 image1.png
2023-05-16 12:44:08      56429 image2.png

Upload local file to S3 bucket

1
2
[~]$ aws s3 cp image3.png s3://exampro-202305/enterprise/
upload: ./image3.png to s3://exampro-202305/enterprise/image3.png

Download file from S3 Bucket to local folder

1
2
[~]$ aws s3 cp s3://exampro-202305/enterprise/image3.png .
download: s3://exampro-202305/enterprise/image3.png to ./image3.png

Create temporary access url that expires in 300 seconds

1
2
[~]$ aws s3 presign s3://exampro-202305/enterprise/image1.jpg --expires-in 300
https://exampro-202305.s3.us-east-1.amazonaws.com/enterprise/image1.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIA2L5XU63TMZNP3ZKG%2F20230516%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230516T071652Z&X-Amz-Expires=300&X-Amz-SignedHeaders=host&X-Amz-Signature=9857e486c04dc3d54e0c881b7bdc1af8b90205e70a23d6d96485a2e5f1b0a489
This post is licensed under CC BY 4.0 by the author.