I have thins link below, and when I try to acess it it appears an xml file saying "Acess denied".
And I need to go to aws managment console and make this part-0000
file public so I can acess it.
Do you know how can I give permissions using boto with python so I can acess this link without needed to go to aws managmet console and make the file public?
downloadLink = 'https://s3.amazonaws.com/myFolder/uploadedfiles/2015423/part-00000'
Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/ . In the Bucket name list, choose the name of the bucket that you want. Choose Permissions. Choose Edit to change the public access settings for the bucket.
How to create S3 bucket using Boto3? To create the Amazon S3 Bucket using the Boto3 library, you need to either create_bucket client or create_bucket resource. Note: Every Amazon S3 Bucket must have a unique name. Moreover, this name must be unique across all AWS accounts and customers.
This should give you an idea:
import boto.s3
conn = boto.s3.connect_to_region('us-east-1') # or region of choice
bucket = conn.get_bucket('myFolder')
key = bucket.lookup('uploadedfiles/2015423/part-00000')
key.set_acl('public-read')
In this case, public-read
is one of the canned ACL policies supported by S3 and would allow anyone to read the file.
from boto3.s3.transfer import S3Transfer
import boto3
# ...
# have all the variables populated which are required below
client = boto3.client('s3', aws_access_key_id=access_key,
aws_secret_access_key=secret_key)
transfer = S3Transfer(client)
transfer.upload_file(filepath, bucket_name, folder_name+"/"+filename)
response = client.put_object_acl(ACL='public-read', Bucket=bucket_name, Key="%s/%s" % (folder_name, filename))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With