本文整理汇总了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': {
}
}
}
]
}
)
示例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': {
}
}
}
]
}
)
示例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': []
}
}
}
]
}
)
示例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'
}
]
}
}
}
]
}
)
示例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')
示例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))
示例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)
示例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)
示例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
})
示例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
示例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
)
示例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)
示例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]
示例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)
示例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)