Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS S3 cmd to automatically make file public while uploading

Description:

Hi, I am trying to ssh a linux server and from that I am trying to upload a file to S3 bucket using AWS cli, and its working fine.

AWS S3 cp /path/to/file s3://sample_bucket --profile=user1

Problem:

But while uploading the file, i want to make that file public too. Is there any command to make the file public, if so then please correct the above given command.

like image 328
Salik47 Avatar asked Nov 27 '18 21:11

Salik47


People also ask

How do you make your ACL public?

If you select Write objects, then anyone can upload, overwrite, or delete objects that are in the bucket. If you select Read bucket permissions, then anyone can view the bucket's ACL. If you select Write bucket permissions, then anyone can change the bucket's ACL.

Are S3 objects public by default?

By default, new S3 bucket settings do not allow public access, but customers can modify these settings to grant public access using policies or object-level permissions.

What is the default setting for S3 storage visibility?

By default, all Amazon S3 buckets and objects are private. Only the resource owner which is the AWS account that created the bucket can access that bucket. The resource owner can, however, choose to grant access permissions to other resources and users.

Can anyone upload to a public S3 bucket?

Before you can upload files to an Amazon S3 bucket, you need write permissions for the bucket. For more information about access permissions, see Identity and access management in Amazon S3. You can upload any file type—images, backups, data, movies, etc.


1 Answers

You can set the Access Control List (ACL) while copying an object. So your command would become.

aws s3 cp /path/to/file s3://sample_bucket --acl public-read

You'll also want to check the buckets Permissions tab and review the Manage public access control lists (ACLs) settings.

like image 73
Michael Hommé Avatar answered Nov 08 '22 00:11

Michael Hommé