当前位置: 首页>>代码示例>>Python>>正文


Python Bucket.set_acl方法代码示例

本文整理汇总了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)
开发者ID:harvard-lil,项目名称:freedata,代码行数:21,代码来源:FreeData.py

示例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
开发者ID:varunarora,项目名称:OCS,代码行数:23,代码来源:ExportUtilities.py


注:本文中的boto.s3.bucket.Bucket.set_acl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。