Reputation: 2290
I'm uploading a file using Amazon's AWS SDK (S3), and everything is working fine. Below is my code:
final AWSCredentials credentials = new AWSCredentials() {
@Override
public String getAWSAccessKeyId() {
return "...myAccessKey...";
}
@Override
public String getAWSSecretKey() {
return "...mySecretKey...";
}
};
final StaticCredentialsProvider credentialsProvider = new StaticCredentialsProvider(credentials);
final TransferManager transferManager = new TransferManager(credentialsProvider);
final Upload upload = transferManager.upload(Config.AWS_IMAGE_BUCKET, "images/" + file.getName(), file);
Problem is, whenever I upload something like this, the permissions are not set to public, so I can't use them in my app.
How can I set the file permissions from my code so that it's viewable by public?
Thanks!
Upvotes: 1
Views: 4850
Reputation: 11808
Choose appropriate ACL policy when you put file in to the bucket.
It can be one of the following option:
1) ACL_AUTHENTICATED_READ
Allow read access to authenticated users.
2) ACL_PRIVATE
Allows only private access to the file.
3) ACL_PUBLIC_READ.
Allows public read access to the file.
4) ACL_PUBLIC_READ_WRITE
Allows public read write access to the file when you write files onto the bucket.
Upvotes: 0
Reputation: 78850
You need to provide a PutObjectRequest with the ACLs you want when you call upload.
Upvotes: 3