diff --git a/qcloud_cos/cos_client.py b/qcloud_cos/cos_client.py index 48dcd07b..3d0e4a68 100644 --- a/qcloud_cos/cos_client.py +++ b/qcloud_cos/cos_client.py @@ -968,7 +968,7 @@ def create_bucket(self, Bucket, **kwargs): method='PUT', url=url, bucket=Bucket, - auth=CosS3Auth(self._conf._secret_id, self._conf._secret_key), + auth=CosS3Auth(self._conf), headers=headers) return None @@ -997,7 +997,7 @@ def delete_bucket(self, Bucket, **kwargs): method='DELETE', url=url, bucket=Bucket, - auth=CosS3Auth(self._conf._secret_id, self._conf._secret_key), + auth=CosS3Auth(self._conf), headers=headers) return None @@ -1242,7 +1242,7 @@ def head_bucket(self, Bucket, **kwargs): method='HEAD', url=url, bucket=Bucket, - auth=CosS3Auth(self._conf._secret_id, self._conf._secret_key), + auth=CosS3Auth(self._conf), headers=headers) return None @@ -2114,7 +2114,7 @@ def list_buckets(self, **kwargs): url=url, bucket=None, headers=headers, - auth=CosS3Auth(self._conf._secret_id, self._conf._secret_key), + auth=CosS3Auth(self._conf), ) data = xml_to_dict(rt.content) if data['Buckets'] is not None and not isinstance(data['Buckets']['Bucket'], list): diff --git a/qcloud_cos/cos_comm.py b/qcloud_cos/cos_comm.py index 6164b5c3..5b644c62 100644 --- a/qcloud_cos/cos_comm.py +++ b/qcloud_cos/cos_comm.py @@ -348,7 +348,10 @@ def get_file_like_object_length(data): else: # support BytesIO file-like object total_length = len(data.getvalue()) - current_position = data.tell() + try: + current_position = data.tell() + except IOError: + current_position = 0 content_len = total_length - current_position return content_len