@@ -190,19 +190,21 @@ def format_bucket(bucket, appid):
190
190
191
191
class CosConfig (object ):
192
192
"""config类,保存用户相关信息"""
193
- def __init__ (self , Appid , Region , Access_id , Access_key , Token = None ):
193
+ def __init__ (self , Appid , Region , Access_id , Access_key , Scheme = 'http' , Token = None ):
194
194
"""初始化,保存用户的信息
195
195
196
196
:param Appid(string): 用户APPID.
197
197
:param Region(string): 地域信息.
198
198
:param Access_id(string): 秘钥SecretId.
199
199
:param Access_key(string): 秘钥SecretKey.
200
+ :param Scheme(string): http/https.
200
201
:param Token(string): 临时秘钥使用的token.
201
202
"""
202
203
self ._appid = Appid
203
204
self ._region = format_region (Region )
204
205
self ._access_id = Access_id
205
206
self ._access_key = Access_key
207
+ self ._scheme = Scheme
206
208
self ._token = Token
207
209
logger .info ("config parameter-> appid: {appid}, region: {region}" .format (
208
210
appid = Appid ,
@@ -219,14 +221,16 @@ def uri(self, bucket, path=None):
219
221
if path :
220
222
if path [0 ] == '/' :
221
223
path = path [1 :]
222
- url = u"http://{bucket}-{uid}.{region}.myqcloud.com/{path}" .format (
224
+ url = u"{scheme}://{bucket}-{uid}.{region}.myqcloud.com/{path}" .format (
225
+ scheme = self ._scheme ,
223
226
bucket = to_unicode (bucket ),
224
227
uid = self ._appid ,
225
228
region = self ._region ,
226
229
path = to_unicode (path )
227
230
)
228
231
else :
229
- url = u"http://{bucket}-{uid}.{region}.myqcloud.com/" .format (
232
+ url = u"{scheme}://{bucket}-{uid}.{region}.myqcloud.com/" .format (
233
+ scheme = self ._scheme ,
230
234
bucket = to_unicode (bucket ),
231
235
uid = self ._appid ,
232
236
region = self ._region
0 commit comments