12
12
FileConflict: "fail (default) | replace | rename"
13
13
FileDescription: Sharepoint description for the file
14
14
"""
15
- def sharepoint_upload (Host , TenantID , ClientID , Secret , SiteName , TargetFilePath , SourceFilePath = "/tmp/default.txt" , Library = "root" , UploadMethod = "Object" , UploadObject = "" , ProxyUse = False , ProxyUrl = "" , ProxyMethod = "https" , FileConflict = "fail" ):
15
+ def sharepoint_upload (Host , TenantID , ClientID , Secret , SiteName , TargetFilePath , SourceFilePath = "/tmp/default.txt" , Library = "root" , UploadMethod = "Object" , UploadObject = "" , ProxyUse = False , ProxyUrl = "" , ProxyMethod = "https" , FileConflict = "fail" , SSLVerify = True ):
16
16
17
17
18
18
import requests
@@ -44,7 +44,7 @@ def sharepoint_upload(Host, TenantID, ClientID, Secret, SiteName, TargetFilePath
44
44
else :
45
45
proxies = {}
46
46
47
- auth = requests .request ("POST" , url , headers = headers , data = payload , proxies = proxies )
47
+ auth = requests .request ("POST" , url , headers = headers , data = payload , proxies = proxies , verify = SSLVerify )
48
48
49
49
if auth .status_code != 200 :
50
50
duration = datetime .now () - start
@@ -60,7 +60,7 @@ def sharepoint_upload(Host, TenantID, ClientID, Secret, SiteName, TargetFilePath
60
60
61
61
# ======= Get Site ID from Site name ====
62
62
SiteName = SiteName .replace (" " , "" )
63
- SiteID = requests .request ("GET" , f"https://graph.microsoft.com/v1.0/sites/{ Host } :/sites/{ SiteName } ?$select=id" , headers = headers , json = payload , proxies = proxies )
63
+ SiteID = requests .request ("GET" , f"https://graph.microsoft.com/v1.0/sites/{ Host } :/sites/{ SiteName } ?$select=id" , headers = headers , json = payload , proxies = proxies , verify = SSLVerify )
64
64
65
65
if SiteID .status_code != 200 :
66
66
duration = datetime .now () - start
@@ -80,7 +80,7 @@ def sharepoint_upload(Host, TenantID, ClientID, Secret, SiteName, TargetFilePath
80
80
else :
81
81
82
82
drive = ""
83
- driveID = requests .request ("GET" , f"https://graph.microsoft.com/v1.0/sites/{ SiteID ['id' ]} /drives?$select=name,id" , headers = headers , json = payload , proxies = proxies )
83
+ driveID = requests .request ("GET" , f"https://graph.microsoft.com/v1.0/sites/{ SiteID ['id' ]} /drives?$select=name,id" , headers = headers , json = payload , proxies = proxies , verify = SSLVerify )
84
84
if driveID .status_code != 200 :
85
85
duration = datetime .now () - start
86
86
return {"result" :"Fail" , "reason" :"Sharepoint get drives" , "duration" : str (duration ), "status" : driveID .status_code , "error" : driveID .json ()}
@@ -111,7 +111,7 @@ def sharepoint_upload(Host, TenantID, ClientID, Secret, SiteName, TargetFilePath
111
111
"fileSize" : FileSize ,
112
112
"name" : TargetFilePath
113
113
}
114
- UploadUrl = requests .request ("POST" , url , headers = headers , json = payload , proxies = proxies )
114
+ UploadUrl = requests .request ("POST" , url , headers = headers , json = payload , proxies = proxies , verify = SSLVerify )
115
115
116
116
if UploadUrl .status_code != 200 :
117
117
duration = datetime .now () - start
@@ -132,7 +132,7 @@ def sharepoint_upload(Host, TenantID, ClientID, Secret, SiteName, TargetFilePath
132
132
# "Authorization": "Bearer " + auth["access_token"]
133
133
}
134
134
135
- upload = requests .put (UploadUrl ["uploadUrl" ], data = UploadObject , headers = headers , proxies = proxies )
135
+ upload = requests .put (UploadUrl ["uploadUrl" ], data = UploadObject , headers = headers , proxies = proxies , verify = SSLVerify )
136
136
if upload .status_code != 201 :
137
137
duration = datetime .now () - start
138
138
return {"result" :"non 201" , "reason" :"Upload file" , "duration" : str (duration ), "status" : upload .status_code , "response" : upload .json ()}
0 commit comments