Skip to content

Commit

Permalink
update entry construction
Browse files Browse the repository at this point in the history
  • Loading branch information
forrest-mao committed May 22, 2015
1 parent fe67bdd commit d182fa9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion qiniu/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,7 @@ def entry(bucket, key):
Returns:
符合七牛API规格的数据格式
"""
return urlsafe_base64_encode('{0}:{1}'.format(bucket, key))
if key is None:
return urlsafe_base64_encode('{0}'.format(bucket))
else:
return urlsafe_base64_encode('{0}:{1}'.format(bucket, key))
6 changes: 6 additions & 0 deletions test_qiniu.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ def test_fetch(self):
assert ret['key'] == 'fetch.html'
assert ret['hash'] == 'FhwVT7vs6xqs1nu_vEdo_4x4qBMB'

def test_fetch_without_key(self):
ret, info = self.bucket.fetch('http://developer.qiniu.com/docs/v6/sdk/python-sdk.html', bucket_name)
print(info)
assert ret['key'] == 'FhwVT7vs6xqs1nu_vEdo_4x4qBMB'
assert ret['hash'] == 'FhwVT7vs6xqs1nu_vEdo_4x4qBMB'

def test_stat(self):
ret, info = self.bucket.stat(bucket_name, 'python-sdk.html')
print(info)
Expand Down

0 comments on commit d182fa9

Please sign in to comment.