|
@@ -34,18 +34,19 @@ def getMDFFromFile(path):
|
|
|
traceback.print_exc()
|
|
|
return None,_length
|
|
|
|
|
|
-def uploadFileByPath(bucket,filepath,uploadpath,headers=None):
|
|
|
- try:
|
|
|
- start_time = time.time()
|
|
|
- log("uploading file of %s"%filepath)
|
|
|
- with open(filepath,"rb") as f:
|
|
|
- bucket.put_object(uploadpath,f,headers=headers)
|
|
|
- log("upload file of %s takes %ds"%(filepath,time.time()-start_time))
|
|
|
- return True
|
|
|
- except Exception as e:
|
|
|
- traceback.print_exc()
|
|
|
- log("upload object failed of %s"%(filepath))
|
|
|
- return False
|
|
|
+def uploadFileByPath(bucket,filepath,uploadpath,headers=None,trytimes=3):
|
|
|
+ for _i in range(trytimes):
|
|
|
+ try:
|
|
|
+ start_time = time.time()
|
|
|
+ log("uploading file of %s"%filepath)
|
|
|
+ with open(filepath,"rb") as f:
|
|
|
+ bucket.put_object(uploadpath,f,headers=headers)
|
|
|
+ log("upload file of %s takes %ds"%(filepath,time.time()-start_time))
|
|
|
+ return True
|
|
|
+ except Exception as e:
|
|
|
+ traceback.print_exc()
|
|
|
+ log("upload object failed of %s"%(filepath))
|
|
|
+ return False
|
|
|
|
|
|
def deleteObject(bucket,objectName):
|
|
|
try:
|
|
@@ -104,7 +105,7 @@ def test_download(filemd5):
|
|
|
|
|
|
|
|
|
if __name__=="__main__":
|
|
|
- # print(getMDFFromFile('1623894475151.pdf'))
|
|
|
+ print(getMDFFromFile('8a9c96a68803c2ad01881d0ee93618e5.pdf'))
|
|
|
# test_download("0852ca62c6e3da56a89a02ed4af87724")
|
|
|
- print(bucket.sign_url("GET","0015//20220623/2022-06-22/WGH001018/1655926900020.png",86500*30))
|
|
|
- print(time.strftime("%Y-%m-%d",time.localtime(1658655178)))
|
|
|
+ # print(bucket.sign_url("GET","0015//20220623/2022-06-22/WGH001018/1655926900020.png",86500*30))
|
|
|
+ # print(time.strftime("%Y-%m-%d",time.localtime(1658655178)))
|