@@ -114,19 +114,21 @@ class UploadFileRequest(BaseRequest):
114
114
UploadFileRequest 单文件上传请求
115
115
"""
116
116
117
- def __init__ (self , bucket_name , cos_path , local_path , biz_attr = u'' , insert_only = 1 ):
117
+ def __init__ (self , bucket_name , cos_path , local_path , biz_attr = u'' , insert_only = 1 , verify_sha1 = False ):
118
118
"""
119
119
120
120
:param bucket_name: bucket的名称
121
121
:param cos_path: cos的绝对路径(目的路径), 从bucket根/开始
122
122
:param local_path: 上传的本地文件路径(源路径)
123
123
:param biz_attr: 文件的属性
124
124
:param insert_only: 是否覆盖写, 0覆盖, 1不覆盖,返回错误
125
+ :param verify_sha1: 分片上传是否带sha1上传,默认为False
125
126
"""
126
127
super (UploadFileRequest , self ).__init__ (bucket_name , cos_path )
127
128
self ._local_path = local_path .strip ()
128
129
self ._biz_attr = biz_attr
129
130
self ._insert_only = insert_only
131
+ self ._verify_sha1 = verify_sha1
130
132
131
133
def set_local_path (self , local_path ):
132
134
"""设置local_path
@@ -173,6 +175,21 @@ def get_insert_only(self):
173
175
"""
174
176
return self ._insert_only
175
177
178
+ def set_verify_sha1 (self , verify_sha1 ):
179
+ """设置enable_sha1
180
+
181
+ :param verify_sha1:
182
+ :return:
183
+ """
184
+ self ._verify_sha1 = verify_sha1
185
+
186
+ def get_verify_sha1 (self ):
187
+ """获取verify_sha1
188
+
189
+ :return:
190
+ """
191
+ return self ._verify_sha1
192
+
176
193
def check_params_valid (self ):
177
194
"""检查参数是否有效
178
195
@@ -198,7 +215,7 @@ class UploadSliceFileRequest(UploadFileRequest):
198
215
UploadSliceFileRequest 分片文件上传请求
199
216
"""
200
217
201
- def __init__ (self , bucket_name , cos_path , local_path , slice_size = 1024 * 1024 , biz_attr = u'' , enable_sha1 = False , max_con = 1 ):
218
+ def __init__ (self , bucket_name , cos_path , local_path , slice_size = 1024 * 1024 , biz_attr = u'' , enable_sha1 = False , max_con = 1 , insert_only = 1 ):
202
219
"""
203
220
204
221
:param bucket_name: bucket的名称
@@ -207,8 +224,9 @@ def __init__(self, bucket_name, cos_path, local_path, slice_size=1024*1024, biz_
207
224
:param slice_size: 文件的属性
208
225
:param biz_attr: 分片大小(字节, 默认1MB)
209
226
:param enable_sha1: 是否启用sha1校验
227
+ :param insert_only: 是否覆盖,默认为1不覆盖
210
228
"""
211
- super (UploadSliceFileRequest , self ).__init__ (bucket_name , cos_path , local_path , biz_attr )
229
+ super (UploadSliceFileRequest , self ).__init__ (bucket_name , cos_path , local_path , biz_attr , insert_only )
212
230
self ._slice_size = slice_size
213
231
self ._enable_sha1 = enable_sha1
214
232
self ._max_con = max_con
@@ -259,7 +277,7 @@ class UploadFileFromBufferRequest(BaseRequest):
259
277
UploadFileFromBufferRequest 内存单文件上传请求
260
278
"""
261
279
262
- def __init__ (self , bucket_name , cos_path , data , biz_attr = u'' , insert_only = 1 ):
280
+ def __init__ (self , bucket_name , cos_path , data , biz_attr = u'' , insert_only = 1 , verify_sha1 = False ):
263
281
"""
264
282
265
283
:param bucket_name: bucket的名称
@@ -272,6 +290,7 @@ def __init__(self, bucket_name, cos_path, data, biz_attr=u'', insert_only=1):
272
290
self ._data = data
273
291
self ._biz_attr = biz_attr
274
292
self ._insert_only = insert_only
293
+ self ._verify_sha1 = verify_sha1
275
294
276
295
def set_data (self , data ):
277
296
"""设置local_path
@@ -318,6 +337,21 @@ def get_insert_only(self):
318
337
"""
319
338
return self ._insert_only
320
339
340
+ def set_verify_sha1 (self , verify_sha1 ):
341
+ """设置enable_sha1
342
+
343
+ :param verify_sha1:
344
+ :return:
345
+ """
346
+ self ._verify_sha1 = verify_sha1
347
+
348
+ def get_verify_sha1 (self ):
349
+ """获取verify_sha1
350
+
351
+ :return:
352
+ """
353
+ return self ._verify_sha1
354
+
321
355
def check_params_valid (self ):
322
356
"""检查参数是否有效
323
357
@@ -339,7 +373,7 @@ class UploadSliceFileFromBufferRequest(UploadFileFromBufferRequest):
339
373
UploadSliceFileFromBufferRequest 内存分片文件上传请求
340
374
"""
341
375
342
- def __init__ (self , bucket_name , cos_path , data , slice_size = 1024 * 1024 , biz_attr = u'' , enable_sha1 = False , max_con = 1 ):
376
+ def __init__ (self , bucket_name , cos_path , data , slice_size = 1024 * 1024 , biz_attr = u'' , enable_sha1 = False , max_con = 1 , insert_only = 1 ):
343
377
"""
344
378
345
379
:param bucket_name: bucket的名称
@@ -348,8 +382,9 @@ def __init__(self, bucket_name, cos_path, data, slice_size=1024*1024, biz_attr=u
348
382
:param slice_size: 文件的属性
349
383
:param biz_attr: 分片大小(字节, 默认1MB)
350
384
:param enable_sha1: 是否启用sha1校验
385
+ :param insert_only: 是否覆盖,默认为1不覆盖
351
386
"""
352
- super (UploadSliceFileFromBufferRequest , self ).__init__ (bucket_name , cos_path , data , biz_attr )
387
+ super (UploadSliceFileFromBufferRequest , self ).__init__ (bucket_name , cos_path , data , biz_attr , insert_only )
353
388
self ._slice_size = slice_size
354
389
self ._enable_sha1 = enable_sha1
355
390
self ._max_con = max_con
0 commit comments