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


Python Minio.set_bucket_policy方法代码示例

本文整理汇总了Python中minio.Minio.set_bucket_policy方法的典型用法代码示例。如果您正苦于以下问题:Python Minio.set_bucket_policy方法的具体用法?Python Minio.set_bucket_policy怎么用?Python Minio.set_bucket_policy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在minio.Minio的用法示例。


在下文中一共展示了Minio.set_bucket_policy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1:

# 需要导入模块: from minio import Minio [as 别名]
# 或者: from minio.Minio import set_bucket_policy [as 别名]
            "Sid":"",
            "Effect":"Allow",
            "Principal":{"AWS":"*"},
            "Action":"s3:ListBucket",
            "Resource":"arn:aws:s3:::my-bucketname"
            },
            {
            "Sid":"",
            "Effect":"Allow",
            "Principal":{"AWS":"*"},
            "Action":"s3:GetObject",
            "Resource":"arn:aws:s3:::my-bucketname/*"
            }
        ]
    }
    client.set_bucket_policy('my-bucketname', json.dumps(policy_read_only))

    # Set bucket policy to read-write for bucket 'my-bucketname'
    policy_read_write = {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Action": ["s3:GetBucketLocation"],
                "Sid": "",
                "Resource": ["arn:aws:s3:::my-bucketname"],
                "Effect": "Allow",
                "Principal": {"AWS": "*"}
            },
            {
                "Action": ["s3:ListBucket"],
                "Sid": "",
开发者ID:minio,项目名称:minio-py,代码行数:33,代码来源:set_bucket_policy.py

示例2: Minio

# 需要导入模块: from minio import Minio [as 别名]
# 或者: from minio.Minio import set_bucket_policy [as 别名]
# Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY and my-bucketname are
# dummy values, please replace them with original values.

from minio import Minio
from minio.error import ResponseError
from minio.policy import Policy

client = Minio('s3.amazonaws.com',
               access_key='YOUR-ACCESSKEYID',
               secret_key='YOUR-SECRETACCESSKEY')

# Make a new bucket
try:
    # Set policy Policy.READ_ONLY to bucket 'my-bucketname' which
    # enables 'my-bucketname' readable by everyone.
    client.set_bucket_policy('my-bucketname', '', Policy.READ_ONLY)

    # Set policy Policy.READ_WRITE to bucket 'my-bucketname' and
    # prefix 'public-folder/' which enables
    # 'my-bucketname/public-folder/' read/writeable by everyone.
    client.set_bucket_policy('my-bucketname', 'public-folder/',
                             Policy.READ_WRITE)

    # Set policy Policy.WRITE_ONLY to bucket 'my-bucketname' and
    # prefix 'incoming' which enables 'my-bucketname/incoming'
    # writeable by everyone.
    client.set_bucket_policy('my-bucketname', 'incoming',
                             Policy.WRITE_ONLY)

    # Set policy Policy.NONE to bucket 'my-bucketname' which
    # removes existing policy and set no access to everyone.
开发者ID:balamurugana,项目名称:minio-py,代码行数:33,代码来源:set_bucket_policy.py


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