本文整理汇总了Python中minio.Minio._list_object_parts方法的典型用法代码示例。如果您正苦于以下问题:Python Minio._list_object_parts方法的具体用法?Python Minio._list_object_parts怎么用?Python Minio._list_object_parts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类minio.Minio
的用法示例。
在下文中一共展示了Minio._list_object_parts方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_empty_list_parts_works
# 需要导入模块: from minio import Minio [as 别名]
# 或者: from minio.Minio import _list_object_parts [as 别名]
def test_empty_list_parts_works(self, mock_connection):
mock_data = '''<?xml version="1.0"?>
<ListPartsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Bucket>bucket</Bucket>
<Key>go1.4.2</Key>
<UploadId>ntWSjzBytPT2xKLaMRonzXncsO10EH4Fc-Iq2-4hG-ulRYB</UploadId>
<Initiator>
<ID>minio</ID>
<DisplayName>minio</DisplayName>
</Initiator>
<Owner>
<ID>minio</ID>
<DisplayName>minio</DisplayName>
</Owner>
<StorageClass>STANDARD</StorageClass>
<PartNumberMarker>0</PartNumberMarker>
<NextPartNumberMarker>0</NextPartNumberMarker>
<MaxParts>1000</MaxParts>
<IsTruncated>false</IsTruncated>
</ListPartsResult>
'''
mock_server = MockConnection()
mock_connection.return_value = mock_server
mock_server.mock_add_request(
MockResponse('GET',
'https://localhost:9000/bucket/key?max-parts=1000&uploadId=upload_id',
{'User-Agent': _DEFAULT_USER_AGENT}, 200, content=mock_data))
client = Minio('localhost:9000')
part_iter = client._list_object_parts('bucket', 'key', 'upload_id')
parts = []
for part in part_iter:
parts.append(part)
eq_(0, len(parts))
示例2: test_list_objects_works
# 需要导入模块: from minio import Minio [as 别名]
# 或者: from minio.Minio import _list_object_parts [as 别名]
def test_list_objects_works(self, mock_connection):
mock_data1 = '''<?xml version="1.0"?>
<ListPartsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Bucket>bucket</Bucket>
<Key>go1.4.2</Key>
<UploadId>ntWSjzBytPT2xKLaMRonzXncsO10EH4Fc-Iq2-4hG-ulRYB</UploadId>
<Initiator>
<ID>minio</ID>
<DisplayName>minio</DisplayName>
</Initiator>
<Owner>
<ID>minio</ID>
<DisplayName>minio</DisplayName>
</Owner>
<StorageClass>STANDARD</StorageClass>
<PartNumberMarker>0</PartNumberMarker>
<NextPartNumberMarker>2</NextPartNumberMarker>
<MaxParts>1000</MaxParts>
<IsTruncated>true</IsTruncated>
<Part>
<PartNumber>1</PartNumber>
<ETag>79b281060d337b9b2b84ccf390adcf74</ETag>
<LastModified>2015-06-03T03:12:34.756Z</LastModified>
<Size>5242880</Size>
</Part>
<Part>
<PartNumber>2</PartNumber>
<ETag>79b281060d337b9b2b84ccf390adcf74</ETag>
<LastModified>2015-06-03T03:12:34.756Z</LastModified>
<Size>5242880</Size>
</Part>
</ListPartsResult>
'''
mock_data2 = '''<?xml version="1.0"?>
<ListPartsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Bucket>bucket</Bucket>
<Key>go1.4.2</Key>
<UploadId>ntWSjzBytPT2xKLaMRonzXncsO10EH4Fc-Iq2-4hG-ulRYB</UploadId>
<Initiator>
<ID>minio</ID>
<DisplayName>minio</DisplayName>
</Initiator>
<Owner>
<ID>minio</ID>
<DisplayName>minio</DisplayName>
</Owner>
<StorageClass>STANDARD</StorageClass>
<PartNumberMarker>0</PartNumberMarker>
<NextPartNumberMarker>0</NextPartNumberMarker>
<MaxParts>1000</MaxParts>
<IsTruncated>false</IsTruncated>
<Part>
<PartNumber>3</PartNumber>
<ETag>79b281060d337b9b2b84ccf390adcf74</ETag>
<LastModified>2015-06-03T03:12:34.756Z</LastModified>
<Size>5242880</Size>
</Part>
<Part>
<PartNumber>4</PartNumber>
<ETag>79b281060d337b9b2b84ccf390adcf74</ETag>
<LastModified>2015-06-03T03:12:34.756Z</LastModified>
<Size>5242880</Size>
</Part>
</ListPartsResult>
'''
mock_server = MockConnection()
mock_connection.return_value = mock_server
mock_server.mock_add_request(
MockResponse('GET',
'https://localhost:9000/bucket/key?max-parts=1000&uploadId=upload_id',
{'User-Agent': _DEFAULT_USER_AGENT}, 200, content=mock_data1))
client = Minio('localhost:9000')
part_iter = client._list_object_parts('bucket', 'key', 'upload_id')
parts = []
for part in part_iter:
mock_server.mock_add_request(
MockResponse('GET',
'https://localhost:9000/bucket/key?max-parts=1000&part-number-marker=2&uploadId=upload_id',
{'User-Agent': _DEFAULT_USER_AGENT}, 200, content=mock_data2))
parts.append(part)
eq_(4, len(parts))