當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。