From 0d782cc220fc16d4c3f11a4a283a4fef1310d41d Mon Sep 17 00:00:00 2001 From: jayzhenghan Date: Fri, 14 Aug 2020 14:25:46 +0800 Subject: [PATCH 1/3] fix bug --- qcloud_cos/cos_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qcloud_cos/cos_client.py b/qcloud_cos/cos_client.py index 08e67167..f651a107 100644 --- a/qcloud_cos/cos_client.py +++ b/qcloud_cos/cos_client.py @@ -2958,7 +2958,7 @@ def download_file(self, Bucket, Key, DestFilePath, PartSize=20, MAZThread=5, Ena max_thread: {4}".format(Bucket, Key, DestFilePath, PartSize, MAZThread)) object_info = self.head_object(Bucket, Key) - file_size = object_info['Content-Length'] + file_size = int(object_info['Content-Length']) if file_size <= 1024*1024*20: response = self.get_object(Bucket, Key, **Kwargs) response['Body'].get_stream_to_file(DestFilePath) From ad27057858390771fd195dc71344c75988d03860 Mon Sep 17 00:00:00 2001 From: jayzhenghan Date: Fri, 14 Aug 2020 14:33:59 +0800 Subject: [PATCH 2/3] fix bug --- qcloud_cos/resumable_downloader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qcloud_cos/resumable_downloader.py b/qcloud_cos/resumable_downloader.py index 01d14090..3bfaab8e 100644 --- a/qcloud_cos/resumable_downloader.py +++ b/qcloud_cos/resumable_downloader.py @@ -73,8 +73,8 @@ def start(self): logger.debug('download success, bucket: {0}, key: {1}'.format(self.__bucket, self.__key)) def __get_record_filename(self, bucket, key, dest_file_path): - dest_file_path_md5 = hashlib.md5(dest_file_path).hexdigest() - key_md5 = hashlib.md5(key).hexdigest() + dest_file_path_md5 = hashlib.md5(dest_file_path.encode("utf-8")).hexdigest() + key_md5 = hashlib.md5(key.encode("utf-8")).hexdigest() return '{0}_{1}.{2}'.format(bucket, key_md5, dest_file_path_md5) def __determine_part_size_internal(self, file_size, part_size): From 9b1dadcc38e0ac0f25c212d028e3557c8fd228ae Mon Sep 17 00:00:00 2001 From: jayzhenghan Date: Fri, 14 Aug 2020 14:39:21 +0800 Subject: [PATCH 3/3] fix bug --- qcloud_cos/resumable_downloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qcloud_cos/resumable_downloader.py b/qcloud_cos/resumable_downloader.py index 3bfaab8e..61e9d2d4 100644 --- a/qcloud_cos/resumable_downloader.py +++ b/qcloud_cos/resumable_downloader.py @@ -90,7 +90,7 @@ def __determine_part_size_internal(self, file_size, part_size): def __splite_to_parts(self): parts = [] file_size = int(self.__object_info['Content-Length']) - num_parts = (file_size + self.__part_size - 1) / self.__part_size + num_parts = int((file_size + self.__part_size - 1) / self.__part_size) for i in range(num_parts): start = i * self.__part_size if i == num_parts - 1: