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) diff --git a/qcloud_cos/resumable_downloader.py b/qcloud_cos/resumable_downloader.py index 01d14090..61e9d2d4 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): @@ -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: