Skip to content

Commit d182fa9

Browse files
committed
update entry construction
1 parent fe67bdd commit d182fa9

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

qiniu/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,7 @@ def entry(bucket, key):
151151
Returns:
152152
符合七牛API规格的数据格式
153153
"""
154-
return urlsafe_base64_encode('{0}:{1}'.format(bucket, key))
154+
if key is None:
155+
return urlsafe_base64_encode('{0}'.format(bucket))
156+
else:
157+
return urlsafe_base64_encode('{0}:{1}'.format(bucket, key))

test_qiniu.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ def test_fetch(self):
125125
assert ret['key'] == 'fetch.html'
126126
assert ret['hash'] == 'FhwVT7vs6xqs1nu_vEdo_4x4qBMB'
127127

128+
def test_fetch_without_key(self):
129+
ret, info = self.bucket.fetch('http://developer.qiniu.com/docs/v6/sdk/python-sdk.html', bucket_name)
130+
print(info)
131+
assert ret['key'] == 'FhwVT7vs6xqs1nu_vEdo_4x4qBMB'
132+
assert ret['hash'] == 'FhwVT7vs6xqs1nu_vEdo_4x4qBMB'
133+
128134
def test_stat(self):
129135
ret, info = self.bucket.stat(bucket_name, 'python-sdk.html')
130136
print(info)

0 commit comments

Comments
 (0)