Skip to content

Commit

Permalink
Merge pull request #85 from dt3310321/s3
Browse files Browse the repository at this point in the history
S3
  • Loading branch information
dt3310321 authored May 14, 2019
2 parents 25a9c35 + fe91948 commit 1212600
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
2 changes: 0 additions & 2 deletions qcloud_cos/cos_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2266,8 +2266,6 @@ def upload_file(self, Bucket, Key, LocalFilePath, PartSize=1, MAXThread=5, Enabl
LocalFilePath=file_name,
PartSize=10,
MAXThread=10,
CacheControl='no-cache',
ContentDisposition='download.txt'
)
"""
file_size = os.path.getsize(LocalFilePath)
Expand Down
4 changes: 2 additions & 2 deletions qcloud_cos/cos_comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def get_md5(data):

def get_content_md5(body):
"""计算任何输入流的md5值"""
if isinstance(body, string_types):
if isinstance(body, text_type) or isinstance(body, binary_type):
return get_md5(body)
elif hasattr(body, 'tell') and hasattr(body, 'seek') and hasattr(body, 'read'):
file_position = body.tell() # 记录文件当前位置
Expand Down Expand Up @@ -359,7 +359,7 @@ def get_file_like_object_length(data):
def check_object_content_length(data):
"""put_object接口和upload_part接口的文件大小不允许超过5G"""
content_len = 0
if type(data) is string_types:
if isinstance(data, text_type) or isinstance(data, binary_type):
content_len = len(to_bytes(data))
elif hasattr(data, 'fileno') and hasattr(data, 'tell'):
content_len = get_file_like_object_length(data)
Expand Down
3 changes: 1 addition & 2 deletions ut/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,7 @@ def test_upload_file_multithreading():
Key=file_name,
LocalFilePath=file_name,
MAXThread=10,
CacheControl='no-cache',
ContentDisposition='download.txt'
EnableMD5=True
)
ed = time.time() # 记录结束时间
if os.path.exists(file_name):
Expand Down

0 comments on commit 1212600

Please sign in to comment.