Skip to content

Commit

Permalink
upload 3.19.11
Browse files Browse the repository at this point in the history
  • Loading branch information
shenqing-github committed Dec 16, 2019
1 parent 4b2c8e9 commit a4fed2b
Show file tree
Hide file tree
Showing 13 changed files with 3,043 additions and 2,952 deletions.
25 changes: 19 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@

Version 3.19.7.2

New Features:
Version 3.19.11

Documentation & Demo:
1. Fixed the issue that package import method using the relative path is incompatible with Python 3.x versions.

Resolved Issues:
1. Fixed the issue that the authentication information header is added when redirection is performed upon a 302 response returned for a GET request.
2. Fixed the issue that the content-type cannot be obtained based on the file name extension if the extension is in uppercase.
3. Fixed the issue that the sequence of request parameters is incorrect in Authentication make_canonicalstring for calculating the authentication value.
4. Fixed the issue that the sample code examples/concurrent_copy_part_sample.py does not process failed requests.
5. Fixed the issue that the sample code examples/concurrent_download_object_sample.py does not process failed requests.
6. Fixed the issue that the sample code examples/concurrent_upload_part_sample.py does not process failed requests.
7. Fixed the issue that some response fields are empty in anonymous access.

-------------------------------------------------------------------------------------------------

Version 3.19.7.1
Expand All @@ -20,7 +24,16 @@ Documentation & Demo:
3. Added the code examples for obtaining access keys in predefined mode and in combination mode to section "Creating an Instance of ObsClient" in OBS Python SDK Developer Guide.
4. Added the security_providers and security_provider_policy parameters to section "Configuring an Instance of ObsClient" in OBS Python SDK Developer Guide.

Resolved Issues:
Resolved issues:

-------------------------------------------------------------------------------------------------

Version 3.19.5.2

Documentation & Demo

Resolved issues:
1. Fixed the issue that an error occurs indicating no attribute when the broken pipe exception occurs during the API calling.
-------------------------------------------------------------------------------------------------

Version 3.19.5.1
Expand Down
26 changes: 24 additions & 2 deletions README_CN.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
Version 3.19.7.2
Version 3.19.11

资料&demo:

修复问题:
1. 修复在GET请求返回302情况下进行重定向会添加鉴权信息头的问题;
2. 修复根据文件名后缀获取content-type类型时不支持大写文件名后缀的问题;
3. 修复Authentication make_canonicalstring计算鉴权接口中请求参数排序有误的问题;
4. 修改示例代码 examples/concurrent_copy_part_sample.py中不处理失败请求的问题;
5. 修改示例代码 examples/concurrent_download_object_sample.py中不处理失败请求的问题;
6. 修改示例代码 examples/concurrent_upload_part_sample.py中不处理失败请求的问题。
7. 修复匿名访问方式下,部分响应字段为空的问题。
-------------------------------------------------------------------------------------------------

Version 3.19.7.2

资料&demo:

Expand All @@ -20,6 +34,14 @@ Version 3.19.7.1
修复问题:
-------------------------------------------------------------------------------------------------

Version 3.19.5.2

资料&demo:

修复问题:
1. 修复调用接口出现broken pipe异常后会导致报错no attribute的问题;
-------------------------------------------------------------------------------------------------

Version 3.19.5.1

资料&demo:
Expand Down Expand Up @@ -91,4 +113,4 @@ Version 3.1.2
3. 修复SDK上传对象接口(ObsClient.setObjectMetadata)接口对contentDisposition参数处理有误的问题;
4. 修改对象临时鉴权访问接口(ObsClient.createSignedUrl)对特殊字符的编码策略,将'~'符号作为URL编码保留字符,解决Python2.x/3.x环境结果不一致的问题;
5. 优化底层代码,提升SDK在Python2.x环境下小文件上传/下载的性能;
6. 修复在linux操作系统下,引入obs包会fork进程的问题;
6. 修复在linux操作系统下,引入obs包会fork进程的问题;
33 changes: 26 additions & 7 deletions examples/concurrent_copy_part_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,39 @@ def doCopyPart(partETags, bucketName, objectKey, partNumber, uploadId, copySourc
resp = obsClient.copyPart(bucketName=bucketName, objectKey=objectKey, partNumber=partNumber, uploadId=uploadId, copySource=copySource, copySourceRange=copySourceRange)
if resp.status < 300:
partETags[partNumber] = resp.body.etag
print('Part#', partNumber, 'done\n')
print('Part#' + str(partNumber) + 'done\n')
else:
print('\tPart#' + str(partNumber) + ' failed\n')

if __name__ == '__main__':
# Constructs a obs client instance with your account for accessing OBS
obsClient = ObsClient(access_key_id=AK, secret_access_key=SK, server=server)
# Create bucket
print('Create a new bucket for demo\n')
obsClient.createBucket(bucketName)
resp = obsClient.createBucket(bucketName)
if resp.status >= 300:
raise Exception('Create Bucket failed')

# # Upload an object to your source bucket
print('Uploading a new object to OBS from a file\n')
obsClient.putFile(sourceBucketName, sourceObjectKey, sampleFilePath)
resp = obsClient.putFile(sourceBucketName, sourceObjectKey, sampleFilePath)
if resp.status >= 300:
raise Exception('putFile failed')

# Claim a upload id firstly
resp = obsClient.initiateMultipartUpload(bucketName, objectKey)
if resp.status >= 300:
raise Exception('initiateMultipartUpload failed')

uploadId = resp.body.uploadId
print('Claiming a new upload id ' + uploadId + '\n')

# 5MB
partSize = 5 * 1024 * 1024
resp = obsClient.getObjectMetadata(sourceBucketName, sourceObjectKey)
if resp.status >= 300:
raise Exception('getObjectMetadata failed')

header = dict(resp.header)
objectSize = int(header.get('content-length'))

Expand Down Expand Up @@ -110,14 +122,17 @@ def doCopyPart(partETags, bucketName, objectKey, partNumber, uploadId, copySourc
p.join()

if len(partETags) != partCount:
raise Exception('Upload multiparts fail due to some parts are not finished yet')
raise Exception('copyParts fail due to some parts are not finished yet')

# View all parts uploaded recently
print('Listing all parts......')
resp = obsClient.listParts(bucketName, objectKey, uploadId)
for part in resp.body.parts:
print('\tPart#' + str(part.partNumber) + ', ETag=' + part.etag)
print('\n')
if resp.status < 300:
for part in resp.body.parts:
print('\tPart#' + str(part.partNumber) + ', ETag=' + part.etag)
print('\n')
else:
raise Exception('listParts failed')

# Complete to upload multiparts

Expand All @@ -131,3 +146,7 @@ def doCopyPart(partETags, bucketName, objectKey, partNumber, uploadId, copySourc
resp = obsClient.completeMultipartUpload(bucketName, objectKey, uploadId, CompleteMultipartUploadRequest(parts))
if resp.status < 300:
print('Succeed to complete multiparts into an object named ' + objectKey + '\n')
else:
print('errorCode:', resp.errorCode)
print('errorMessage:', resp.errorMessage)
raise Exception('completeMultipartUpload failed')
23 changes: 18 additions & 5 deletions examples/concurrent_download_object_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,32 @@ def doGetObject(lock, completedBlocks, bucketName, objectKey, startPos, endPos,
break
f.write(chunk)
response.close()
print('Part#', i+1, 'done\n')
print('Part#' + str(i+1) + 'done\n')
with lock:
completedBlocks.value += 1
else:
print('\tPart#' + str(i+1) + ' failed\n')

if __name__ == '__main__':
# Constructs a obs client instance with your account for accessing OBS
obsClient = ObsClient(access_key_id=AK, secret_access_key=SK, server=server)
# Create bucket
print('Create a new bucket to upload file\n')
obsClient.createBucket(bucketName)
resp = obsClient.createBucket(bucketName)
if resp.status >= 300:
raise Exception('Create Bucket failed')

# Upload an object to your bucket
print('Uploading a new object to OBS from a file\n')
obsClient.putFile(bucketName, objectKey, sampleFilePath)
resp = obsClient.putFile(bucketName, objectKey, sampleFilePath)
if resp.status >= 300:
raise Exception('putFile failed')

# Get size of the object
resp = obsClient.getObjectMetadata(bucketName, objectKey)
if resp.status >= 300:
raise Exception('getObjectMetadata failed')

header = dict(resp.header)
objectSize = int(header.get('content-length'))

Expand Down Expand Up @@ -130,10 +139,14 @@ class Temp(object):
for p in processes:
p.join()

if not IS_WINDOWS and completedBlocks.value != blockCount:
if completedBlocks.value != blockCount:
raise Exception('Download fails due to some blocks are not finished yet')

print('Succeed to download object ' + objectKey + '\n')

print('Deleting object ' + objectKey + '\n')
obsClient.deleteObject(bucketName, objectKey)
resp = obsClient.deleteObject(bucketName, objectKey)
if resp.status < 300:
print('Deleting object ' + objectKey + ' Succeed\n')
else:
raise Exception('Deleting object failed')
25 changes: 20 additions & 5 deletions examples/concurrent_upload_part_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,24 @@ def doUploadPart(partETags, bucketName, objectKey, partNumber, uploadId, filePat
resp = obsClient.uploadPart(bucketName, objectKey, partNumber, uploadId, content=filePath, isFile=True, partSize=partSize, offset=offset)
if resp.status < 300:
partETags[partNumber] = resp.body.etag
print('Part#', partNumber, 'done\n')
print('Part#' + str(partNumber) + 'done\n')
else:
print('\tPart#' + str(partNumber) + ' failed\n')

if __name__ == '__main__':
# Constructs a obs client instance with your account for accessing OBS
obsClient = ObsClient(access_key_id=AK, secret_access_key=SK, server=server)
# Create bucket
print('Create a new bucket for demo\n')
obsClient.createBucket(bucketName)
resp = obsClient.createBucket(bucketName)
if resp.status >= 300:
raise Exception('Create Bucket failed')

# Claim a upload id firstly
resp = obsClient.initiateMultipartUpload(bucketName, objectKey)
if resp.status >= 300:
raise Exception('initiateMultipartUpload failed')

uploadId = resp.body.uploadId
print('Claiming a new upload id ' + uploadId + '\n')

Expand Down Expand Up @@ -107,9 +114,13 @@ def doUploadPart(partETags, bucketName, objectKey, partNumber, uploadId, filePat
# View all parts uploaded recently
print('Listing all parts......')
resp = obsClient.listParts(bucketName, objectKey, uploadId)
for part in resp.body.parts:
print('\tPart#' + str(part.partNumber) + ', ETag=' + part.etag)
print('\n')
if resp.status < 300:
for part in resp.body.parts:
print('\tPart#' + str(part.partNumber) + ', ETag=' + part.etag)
print('\n')
else:
raise Exception('listParts failed')


# Complete to upload multiparts

Expand All @@ -124,4 +135,8 @@ def doUploadPart(partETags, bucketName, objectKey, partNumber, uploadId, filePat

if resp.status < 300:
print('Succeed to complete multiparts into an object named ' + objectKey + '\n')
else:
print('errorCode:', resp.errorCode)
print('errorMessage:', resp.errorMessage)
raise Exception('completeMultipartUpload failed')

Binary file not shown.
1 change: 1 addition & 0 deletions release/huaweicloud-obs-sdk-python_3.19.11.tar.gz.sha256
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
62121eb31cfa154fcb8eb750e3029224de5fb5c696526cb06ba253eb128b1d4a *huaweicloud-obs-sdk-python_3.19.11.tar.gz
9 changes: 4 additions & 5 deletions src/obs/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,17 @@ def __make_canonicalstring(self, method, bucket_name, key, path_args, headers, e
str_list.append('/')

if path_args:
e1 = '?'
e2 = '&'
e = '?'
cannoList = sorted(path_args.items(), key=lambda d: d[0])
for path_key, path_value in cannoList:
if path_key.lower() in const.ALLOWED_RESOURCE_PARAMTER_NAMES or path_key.lower().startswith(self.ha._get_header_prefix()):
path_key = util.encode_item(path_key, '/')
if path_value is None:
e1 += path_key + '&'
e += path_key + '&'
continue
e2 += path_key + '=' + util.to_string(path_value) + '&'
e += path_key + '=' + util.to_string(path_value) + '&'

e = (e1 + e2).replace('&&', '&').replace('?&', '?')[:-1]
e = e[:-1]
str_list.append(e)
return ''.join(str_list)

Expand Down
Loading

0 comments on commit a4fed2b

Please sign in to comment.