本文整理汇总了Python中boto.s3.bucket.Bucket.set_acl方法的典型用法代码示例。如果您正苦于以下问题:Python Bucket.set_acl方法的具体用法?Python Bucket.set_acl怎么用?Python Bucket.set_acl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boto.s3.bucket.Bucket
的用法示例。
在下文中一共展示了Bucket.set_acl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_to_aws
# 需要导入模块: from boto.s3.bucket import Bucket [as 别名]
# 或者: from boto.s3.bucket.Bucket import set_acl [as 别名]
def send_to_aws(self):
"""Everything should be packaged now. Let's send it to S3"""
# Establish connection to AWS and upload tarball
conn = S3Connection(self.config.get('general', 'aws_key'), self.config.get('general', 'aws_secret_key'))
bucket = Bucket(conn, self.config.get('general', 'bucket_name'))
tarball_key = Key(bucket)
tarball_key.key = self.config.get('general', 'tarball_name')
tarball_path = self.config.get('general', 'dump_path') + self.config.get('general', 'tarball_name')
tarball_key.set_contents_from_filename(tarball_path)
# uncomment the following to make the bucket publicly downloadable
bucket.set_acl('public-read', tarball_key.key)
# Upload the stats file
stats_key = Key(bucket)
stats_key.key = 'stats.json'
stats_key.set_contents_from_filename(self.config.get('general', 'dump_path') + 'stats.json')
# uncomment the following to make the bucket publicly downloadable
bucket.set_acl('public-read', stats_key.key)
示例2: export_to_aws
# 需要导入模块: from boto.s3.bucket import Bucket [as 别名]
# 或者: from boto.s3.bucket.Bucket import set_acl [as 别名]
def export_to_aws(filename, bucket_name, s3_filename=None):
# Get the document and push to an S3 bucket.
from boto.s3.connection import S3Connection
from boto.s3.bucket import Bucket
from boto.s3.key import Key
try:
conn = S3Connection('AKIAIDFEDRWJ4BW5JGMQ', '0b5+2w+/RMRu4HtvziE3VGwrnZdns68WiZ0GGg+2')
bucket = Bucket(conn, bucket_name)
key = Key(bucket)
key.key = s3_filename if s3_filename else filename
key.set_contents_from_filename(filename)
bucket.set_acl('public-read', s3_filename if s3_filename else filename)
# Print the entire URL in the stdout
return 'http://' + bucket_name + '.s3.amazonaws.com/' + (
s3_filename if s3_filename else filename)
except Exception, e:
print e