没有简单的方法,但是您可以从存储桶所在的区域(
get_bucket_location),存储桶名称和存储键构造URL :
bucket_name = "my-aws-bucket"key = "upload-file"s3 = boto3.resource('s3')bucket = s3.Bucket(bucket_name)bucket.upload_file("upload.txt", key)location = boto3.client('s3').get_bucket_location(Bucket=bucket_name)['LocationConstraint']url = "https://s3-%s.amazonaws.com/%s/%s" % (location, bucket_name, key)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)