Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to mark a certain S3 file as Make Public

How to mark a certain S3 file as Make Public via the webservices API.

like image 939
priya Avatar asked Apr 07 '12 13:04

priya


People also ask

How do I grant access to a specific S3 bucket?

Select the group that you just created, e.g. S3OneFS , and click “Group Actions”. Select “Add Users to Group”. Then, select your user, e.g. ObjectiveFS , and click “Add Users”. You can now use your “Access Key ID” and “Secret Access Key” to run ObjectiveFS restricted to a single bucket.

How a can bucket be protected to be modified by certain users only?

First select a bucket and click the Properties option within the Actions drop down box. Now select the Permissions tab of the Properties panel. Verify that there is no grant for Everyone or Authenticated Users. If one or both exist, remove the Everyone and Authenticated Users grantees.

Can a private S3 bucket have public objects?

Steps to allow public access to private AWS S3 bucket files: Click on the private S3 bucket with the object that you want to make public. Click on the Permissions tab. Click Edit on the Block public access section. Click on the Block all public access to uncheck and disable the options.

How do you limit access to an S3 bucket by source IP?

To allow users to perform S3 actions on the bucket from the VPC endpoints or IP addresses, you must explicitly allow the user-level permissions. You can explicitly allow user-level permissions on either an AWS Identity and Access Management (IAM) policy or another statement in the bucket policy.


1 Answers

Use method setCannedAcl(CannedAccessControlList.PublicRead) to change Access control rights. Read java doc for details here

Sample Code:

BasicAWSCredentials basicAWSCredentials = new BasicAWSCredentials(ACCESS_KEY,SECRET_KEY);   
AmazonS3 s3 = new AmazonS3Client(basicAWSCredentials);

PutObjectRequest putObj = new PutObjectRequest(bucketName, objectKey, fileToUpload);

// making the object Public
putObj.setCannedAcl(CannedAccessControlList.PublicRead);

s3.putObject(putObj);
like image 166
shashankaholic Avatar answered Sep 20 '22 04:09

shashankaholic