Skip to content

Commit 86addc0

Browse files
authored
Merge pull request #97 from dt3310321/s3
S3
2 parents e859ec7 + faf288f commit 86addc0

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

qcloud_cos/cos_client.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class CosConfig(object):
3131
"""config类,保存用户相关信息"""
3232
def __init__(self, Appid=None, Region=None, SecretId=None, SecretKey=None, Token=None, Scheme=None, Timeout=None,
3333
Access_id=None, Access_key=None, Secret_id=None, Secret_key=None,
34-
Endpoint=None, IP=None, Port=None, Anonymous=None, UA=None):
34+
Endpoint=None, IP=None, Port=None, Anonymous=None, UA=None, Proxies=None):
3535
"""初始化,保存用户的信息
3636
3737
:param Appid(string): 用户APPID.
@@ -50,6 +50,7 @@ def __init__(self, Appid=None, Region=None, SecretId=None, SecretKey=None, Token
5050
:param Port(int): 访问COS的port
5151
:param Anonymous(bool): 是否使用匿名访问COS
5252
:param UA(string): 使用自定义的UA来访问COS
53+
:param Proxies(dict): 使用代理来访问COS
5354
"""
5455
self._appid = to_unicode(Appid)
5556
self._token = to_unicode(Token)
@@ -60,6 +61,7 @@ def __init__(self, Appid=None, Region=None, SecretId=None, SecretKey=None, Token
6061
self._port = Port
6162
self._anonymous = Anonymous
6263
self._ua = UA
64+
self._proxies = Proxies
6365

6466
if Scheme is None:
6567
Scheme = u'https'
@@ -217,15 +219,15 @@ def send_request(self, method, url, bucket, timeout=30, **kwargs):
217219
for j in range(self._retry + 1):
218220
try:
219221
if method == 'POST':
220-
res = self._session.post(url, timeout=timeout, **kwargs)
222+
res = self._session.post(url, timeout=timeout, proxies=self._conf._proxies, **kwargs)
221223
elif method == 'GET':
222-
res = self._session.get(url, timeout=timeout, **kwargs)
224+
res = self._session.get(url, timeout=timeout, proxies=self._conf._proxies, **kwargs)
223225
elif method == 'PUT':
224-
res = self._session.put(url, timeout=timeout, **kwargs)
226+
res = self._session.put(url, timeout=timeout, proxies=self._conf._proxies, **kwargs)
225227
elif method == 'DELETE':
226-
res = self._session.delete(url, timeout=timeout, **kwargs)
228+
res = self._session.delete(url, timeout=timeout, proxies=self._conf._proxies, **kwargs)
227229
elif method == 'HEAD':
228-
res = self._session.head(url, timeout=timeout, **kwargs)
230+
res = self._session.head(url, timeout=timeout, proxies=self._conf._proxies, **kwargs)
229231
if res.status_code < 400: # 2xx和3xx都认为是成功的
230232
return res
231233
except Exception as e: # 捕获requests抛出的如timeout等客户端错误,转化为客户端错误

qcloud_cos/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11

2-
__version__ = '5.1.7.3'
2+
__version__ = '5.1.7.4'

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def long_description():
1616

1717
setup(
1818
name='cos-python-sdk-v5',
19-
version='1.7.3',
19+
version='1.7.4',
2020
url='https://www.qcloud.com/',
2121
license='MIT',
2222
author='tiedu, lewzylu, channingliu',

0 commit comments

Comments
 (0)