Skip to content

Commit

Permalink
Add bucket versioning,location,head
Browse files Browse the repository at this point in the history
  • Loading branch information
dt3310321 committed Oct 19, 2017
1 parent d9b2ffb commit 16ef8b8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
6 changes: 4 additions & 2 deletions qcloud_cos/cos_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def mapped(headers):
return _headers


def format_xml(data, root, lst):
def format_xml(data, root, lst=list()):
"""将dict转换为xml"""
xml_config = dicttoxml(data, item_func=lambda x: x, custom_root=root, attr_type=False)
for i in lst:
Expand Down Expand Up @@ -814,7 +814,9 @@ def get_bucket_location(self, Bucket, **kwargs):
url=url,
auth=CosS3Auth(self._conf._access_id, self._conf._access_key),
headers=headers)
data = xml_to_dict(rt.text)
root = xml.etree.ElementTree.fromstring(rt.text)
data = dict()
data['LocationConstraint'] = root.text
return data

def head_bucket(self, Bucket, **kwargs):
Expand Down
23 changes: 23 additions & 0 deletions qcloud_cos/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,29 @@ def Test():
Bucket=test_bucket
)

print "test put bucket versioning " + test_bucket
response = client.put_bucket_versioning(
Bucket=test_bucket,
Status='Enabled'
)

print "test get bucket versioning " + test_bucket
response = client.get_bucket_versioning(
Bucket=test_bucket
)
print response

print "test get bucket location " + test_bucket
response = client.get_bucket_location(
Bucket=test_bucket
)
print response

print "test head bucket " + test_bucket
response = client.head_bucket(
Bucket=test_bucket
)

print "Test Get Presigned Download URL "
url = client.get_presigned_download_url(
Bucket=test_bucket,
Expand Down

0 comments on commit 16ef8b8

Please sign in to comment.