AWS CLI Upload / Copy Folders with Files to S3 Bucket
In this tutorial, we'll learn how to upload/copy folders with files to the S3 bucket. Let's get started:
The AWS Command Line Interface (AWS CLI) is a unified tool to manage your AWS services. First, you have to install AWS CLI on your machine. After installation, you can run this command to check whether it is installed correctly or not:
aws --version
It is very easy to upload folders with files to S3 using, aws s3 cp
command. It will require the --recursive
parameter to copy multiple files:
aws s3 cp /PATH/DIR s3://BUCKET_NAME –recursive
You can also upload to a specific folder of S3:
aws s3 cp /PATH/DIR s3://BUCKET_NAME/DIR –recursive
An example:
aws s3 cp /var/www/shouts.dev/uploads s3://shouts/uploads
By default, AWS CLI uploads files in private mode. We can set the Access Control List (ACL) while copying an object. We just need to add --acl public-read
option at the end of the command:
aws s3 cp /PATH/DIR s3://BUCKET_NAME/DIR –recursive --acl public-read
Md Obydullah
Software Engineer | Ethical Hacker & Cybersecurity...
Md Obydullah is a software engineer and full stack developer specialist at Laravel, Django, Vue.js, Node.js, Android, Linux Server, and Ethichal Hacking.