Python 3 Boto 3, AWS S3: Get object URL

后端 未结 4 2124
Happy的楠姐
Happy的楠姐 2020-12-19 00:38

I need to retrieve an public object URL directly after uploading a file, this to be able to store it in a database. This is my upload code:

   s3 = boto3.res         


        
4条回答
  •  清酒与你
    2020-12-19 01:02

    Just a small note. The function call

    location = 
        boto3.client('s3').get_bucket_location(Bucket=bucket_name['LocationConstraint']
    

    may return location = None if the bucket is in the region 'us-east-1'. Therefore, I'd amend the above answer and add a line below that line:

    if location == None: location = 'us-east-1'
    

提交回复
热议问题