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


Python minio.Minio方法代码示例

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


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

示例1: test_notification_config_filterspec_is_valid_2

# 需要导入模块: import minio [as 别名]
# 或者: from minio import Minio [as 别名]
def test_notification_config_filterspec_is_valid_2(self):
        client = Minio('localhost:9000')
        client.set_bucket_notification(
            'my-test-bucket',
            {
                'QueueConfigurations': [
                    {
                        'Id': '1',
                        'Arn': 'arn1',
                        'Events': ['s3:ObjectCreated:*'],
                        'Filter': {
                            'S3Key': {
                            }
                        }
                    }
                ]
            }
        ) 
开发者ID:minio,项目名称:minio-py,代码行数:20,代码来源:set_bucket_notification_test.py

示例2: test_notification_config_filterspec_is_valid_3

# 需要导入模块: import minio [as 别名]
# 或者: from minio import Minio [as 别名]
def test_notification_config_filterspec_is_valid_3(self):
        client = Minio('localhost:9000')
        client.set_bucket_notification(
            'my-test-bucket',
            {
                'QueueConfigurations': [
                    {
                        'Id': '1',
                        'Arn': 'arn1',
                        'Events': ['s3:ObjectCreated:*'],
                        'Filter': {
                            'Key': {
                            }
                        }
                    }
                ]
            }
        ) 
开发者ID:minio,项目名称:minio-py,代码行数:20,代码来源:set_bucket_notification_test.py

示例3: test_notification_config_filterspec_is_valid_4

# 需要导入模块: import minio [as 别名]
# 或者: from minio import Minio [as 别名]
def test_notification_config_filterspec_is_valid_4(self):
        client = Minio('localhost:9000')
        client.set_bucket_notification(
            'my-test-bucket',
            {
                'QueueConfigurations': [
                    {
                        'Id': '1',
                        'Arn': 'arn1',
                        'Events': ['s3:ObjectCreated:*'],
                        'Filter': {
                            'Key': {
                                'FilterRules': []
                            }
                        }
                    }
                ]
            }
        ) 
开发者ID:minio,项目名称:minio-py,代码行数:21,代码来源:set_bucket_notification_test.py

示例4: test_notification_config_filterspec_is_valid_6

# 需要导入模块: import minio [as 别名]
# 或者: from minio import Minio [as 别名]
def test_notification_config_filterspec_is_valid_6(self):
        client = Minio('localhost:9000')
        client.set_bucket_notification(
            'my-test-bucket',
            {
                'QueueConfigurations': [
                    {
                        'Id': '1',
                        'Arn': 'arn1',
                        'Events': ['s3:ObjectCreated:*'],
                        'Filter': {
                            'Key': {
                                'FilterRules': [
                                    {
                                        'Name': 'ab',
                                        'Value': 'abc'
                                    }
                                ]
                            }
                        }
                    }
                ]
            }
        ) 
开发者ID:minio,项目名称:minio-py,代码行数:26,代码来源:set_bucket_notification_test.py

示例5: test_stat_object_works

# 需要导入模块: import minio [as 别名]
# 或者: from minio import Minio [as 别名]
def test_stat_object_works(self, mock_connection):
        mock_headers = {
            'content-type': 'application/octet-stream',
            'last-modified': 'Fri, 26 Jun 2015 19:05:37 GMT',
            'content-length': 11,
            'etag': '5eb63bbbe01eeed093cb22bb8f5acdc3'
        }
        mock_server = MockConnection()
        mock_connection.return_value = mock_server
        mock_server.mock_add_request(
            MockResponse('HEAD',
                         'https://localhost:9000/hello/world',
                         {'User-Agent': _DEFAULT_USER_AGENT}, 200,
                         response_headers=mock_headers)
        )
        client = Minio('localhost:9000')
        client.stat_object('hello', 'world') 
开发者ID:minio,项目名称:minio-py,代码行数:19,代码来源:stat_object_test.py

示例6: test_empty_list_objects_works

# 需要导入模块: import minio [as 别名]
# 或者: from minio import Minio [as 别名]
def test_empty_list_objects_works(self, mock_connection):
        mock_data = '''<?xml version="1.0" encoding="UTF-8"?>
<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
  <Name>bucket</Name>
  <Prefix></Prefix>
  <KeyCount>0</KeyCount>
  <MaxKeys>1000</MaxKeys>
  <Delimiter></Delimiter>
  <IsTruncated>false</IsTruncated>
</ListBucketResult>'''
        mock_server = MockConnection()
        mock_connection.return_value = mock_server
        mock_server.mock_add_request(
            MockResponse(
                'GET',
                'https://localhost:9000/bucket/?list-type=2&prefix=&'
                'start-after=',
                {'User-Agent': _DEFAULT_USER_AGENT}, 200, content=mock_data)
        )
        client = Minio('localhost:9000')
        object_iter = client.list_objects_v2('bucket', recursive=True)
        objects = []
        for obj in object_iter:
            objects.append(obj)
        eq_(0, len(objects)) 
开发者ID:minio,项目名称:minio-py,代码行数:27,代码来源:list_objects_v2_test.py

示例7: test_bucket_exists_works

# 需要导入模块: import minio [as 别名]
# 或者: from minio import Minio [as 别名]
def test_bucket_exists_works(self, mock_connection):
        mock_server = MockConnection()
        mock_connection.return_value = mock_server
        mock_server.mock_add_request(
            MockResponse('HEAD',
                         'https://localhost:9000/hello/',
                         {'User-Agent': _DEFAULT_USER_AGENT},
                         200)
        )
        client = Minio('localhost:9000')
        result = client.bucket_exists('hello')
        eq_(True, result)
        mock_server.mock_add_request(
            MockResponse('HEAD',
                         'https://localhost:9000/goodbye/',
                         {'User-Agent': _DEFAULT_USER_AGENT},
                         404)
        )
        false_result = client.bucket_exists('goodbye')
        eq_(False, false_result) 
开发者ID:minio,项目名称:minio-py,代码行数:22,代码来源:bucket_exist_test.py

示例8: test_empty_list_buckets_works

# 需要导入模块: import minio [as 别名]
# 或者: from minio import Minio [as 别名]
def test_empty_list_buckets_works(self, mock_connection):
        mock_data = ('<ListAllMyBucketsResult '
                     'xmlns="http://s3.amazonaws.com/doc/2006-03-01/">'
                     '<Buckets></Buckets><Owner><ID>minio</ID><DisplayName>'
                     'minio</DisplayName></Owner></ListAllMyBucketsResult>')
        mock_server = MockConnection()
        mock_connection.return_value = mock_server
        mock_server.mock_add_request(
            MockResponse('GET', 'https://localhost:9000/',
                         {'User-Agent': _DEFAULT_USER_AGENT},
                         200, content=mock_data)
        )
        client = Minio('localhost:9000')
        buckets = client.list_buckets()
        count = 0
        for bucket in buckets:
            count += 1
        eq_(0, count) 
开发者ID:minio,项目名称:minio-py,代码行数:20,代码来源:list_buckets_test.py

示例9: upload_url

# 需要导入模块: import minio [as 别名]
# 或者: from minio import Minio [as 别名]
def upload_url(self, request):
        """
        Generates the presigned URL for uploading and retrieving
        the file
        """
        minio = Minio(MINIO['ENDPOINT'],
                      access_key=MINIO['ACCESS_KEY'],
                      secret_key=MINIO['SECRET_KEY'],
                      secure=MINIO['USE_SSL'])

        object_name = uuid.uuid4().hex
        put_url = minio.presigned_put_object(
            bucket_name=MINIO['BUCKET_NAME'],
            object_name=object_name,
            expires=MINIO['EXPIRY'])

        get_url = minio.presigned_get_object(
            bucket_name=MINIO['BUCKET_NAME'],
            object_name=object_name,
            expires=MINIO['EXPIRY'])

        return Response({
            'put': put_url,
            'get': get_url
        }) 
开发者ID:bcgov,项目名称:tfrs,代码行数:27,代码来源:Document.py

示例10: load_from_minio

# 需要导入模块: import minio [as 别名]
# 或者: from minio import Minio [as 别名]
def load_from_minio(self, bucket_name, object_name):
        access_key = os.getenv('MINIO_ACCESS_KEY', None)
        secret_key = os.getenv('MINIO_SECRET_KEY', None)
        endpoint = os.getenv('MINIO_ENDPOINT', None)

        minio = Minio(endpoint, access_key=access_key, secret_key=secret_key, secure=False)
        data = minio.get_object(bucket_name, object_name)

        chunks = []

        for buf in data.stream():
            chunks.append(buf)

        source = b''.join(chunks).decode('utf-8')
        mod = self._load_from_string(source)
        return mod['script_class'], source 
开发者ID:bcgov,项目名称:tfrs,代码行数:18,代码来源:_loader.py

示例11: delete_attachments

# 需要导入模块: import minio [as 别名]
# 或者: from minio import Minio [as 别名]
def delete_attachments(document_id, attachment_ids):
        """
        Sends a request to the minio instance to delete the files associated
        to the DocumentFile records related to the provided parameters
        """
        minio = Minio(MINIO['ENDPOINT'],
                      access_key=MINIO['ACCESS_KEY'],
                      secret_key=MINIO['SECRET_KEY'],
                      secure=MINIO['USE_SSL'])

        attachments = DocumentFileAttachment.objects.filter(
            document_id=document_id,  # additional security
            id__in=attachment_ids
        )

        object_names = map(DocumentService.get_filename, attachments)
        for error in minio.remove_objects(MINIO['BUCKET_NAME'], object_names):
            logging.error(error)

        attachments.update(
            is_removed=True
        ) 
开发者ID:bcgov,项目名称:tfrs,代码行数:24,代码来源:DocumentService.py

示例12: __init__

# 需要导入模块: import minio [as 别名]
# 或者: from minio import Minio [as 别名]
def __init__(self):
        self.logger = logging.getLogger('run.s3upload')
        self.minio = Minio(config['s3_server'],
                           access_key=config['s3_access_key'],
                           secret_key=config['s3_secret_key'],
                           secure=True) 
开发者ID:fzxiao233,项目名称:Auto_Record_Matsuri,代码行数:8,代码来源:upload.py

示例13: _init_client

# 需要导入模块: import minio [as 别名]
# 或者: from minio import Minio [as 别名]
def _init_client(self, server):
        server_id = server.id()
        if server_id not in self._servers:
            if not server.ssl_verify:
                pool = PoolManager(cert_reqs='CERT_NONE')
            else:
                pool = None
            self._servers[server_id] = Minio(server.endpoint, server.access_key, server.secret_key, secure=server.secure, http_client=pool)
        return self._servers[server_id] 
开发者ID:MaibornWolff,项目名称:dcos-deploy,代码行数:11,代码来源:s3.py

示例14: upload_minio

# 需要导入模块: import minio [as 别名]
# 或者: from minio import Minio [as 别名]
def upload_minio(artifacts):
    minio_host = os.environ['MINIO_HOST']
    minioClient = Minio(minio_host+':9000', access_key='minio', secret_key='minio123', secure=False)

    for a in artifacts:
        try:
           file_stat = os.stat(a)
           file_data = open(a, 'rb')
           minioClient.put_object('artifacts', package_name()+'/'+os.path.basename(a), file_data, file_stat.st_size, content_type='application/vnd.dcos.universe.repo+json;charset=utf-8;version=v4')
        except ResponseError as err:
           print(err) 
开发者ID:mesosphere,项目名称:dcosdev,代码行数:13,代码来源:dcosdev.py

示例15: test_object_is_string

# 需要导入模块: import minio [as 别名]
# 或者: from minio import Minio [as 别名]
def test_object_is_string(self):
        client = Minio('localhost:9000')
        client.copy_object('hello', 12, 12) 
开发者ID:minio,项目名称:minio-py,代码行数:5,代码来源:copy_object_test.py


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