Sub SearchForFolderID(suchFolder As String, parrent As String)
Log("-------------------")
Log("SearchForFolerID")
Log("Folder:" & suchFolder)
Log("Parrent:" & parrent)
Dim H As HttpJob
h.Initialize("", Me)
If parrent="" Then
h.Download2("https://www.googleapis.com/drive/v3/files", _
Array As String("access_token", myAccessToken, _
"corpora", "user", _
"q","mimeType='application/vnd.google-apps.folder' and" & _
"name='" & suchFolder & "' and " & _
"trashed=false"))
Else
h.Download2("https://www.googleapis.com/drive/v3/files", _
Array As String("access_token", myAccessToken, _
"corpora", "user", _
"q","mimeType='application/vnd.google-apps.folder' and" & _
"name='" & suchFolder & "' and " & _
"'" & parrent & "' in parents and " & _
"trashed=false"))
End If
Wait For (h) JobDone(h As HttpJob)
If h.Success Then
Log(h.GetString)
Dim j As JSONParser
Dim Map1,fileEntry As Map
Dim files As List
J.Initialize(h.GetString)
files.Initialize
Map1 = J.NextObject
files = Map1.Get("files")
h.Release
For i = 0 To files.Size - 1
fileEntry = files.Get(i)
If fileEntry.Get("name") = suchFolder And _
fileEntry.Get("mimeType") = "application/vnd.google-apps.folder" Then
CallSub2(evModule, evName & "_FolderFound", fileEntry.Get("id"))
Return
End If
Next
CallSub2(evModule, evName & "_FolderFound", "")
End If
End Sub
Sub SearchForFileID(suchFile As String, parrent As String)
Log("-------------------")
Log("SearchForFIleID")
Log("File:" & suchFile)
Log("Parrent" & parrent)
Dim H As HttpJob
h.Initialize("", Me)
If parrent="" Then
h.Download2("https://www.googleapis.com/drive/v3/files", _
Array As String("access_token", myAccessToken, _
"corpora", "user", _
"q","mimeType!='application/vnd.google-apps.folder' and" & _
"name='" & suchFile & "' and " & _
"trashed=false"))
Else
h.Download2("https://www.googleapis.com/drive/v3/files", _
Array As String("access_token", myAccessToken, _
"corpora", "user", _
"q","mimeType!='application/vnd.google-apps.folder' and" & _
"name='" & suchFile & "' and " & _
"'" & parrent & "' in parents and " & _
"trashed=false"))
End If
If h.Success Then
Log(h.GetString)
Dim j As JSONParser
Dim Map1,fileEntry As Map
Dim files As List
J.Initialize(h.GetString)
files.Initialize
Map1 = J.NextObject
files = Map1.Get("files")
H.Release
For i = 0 To files.Size - 1
fileEntry = files.Get(i)
If fileEntry.Get("name") = suchFile Then
CallSub2(evModule, evName & "_FileFound", fileEntry.Get("id"))
Return
End If
Next
CallSub2(evModule, evName & "_FolderFound", "")
End If
End Sub
Sub ShowFileList(parrent As String)
Log ("Show the File List")
Dim H As HttpJob
h.Initialize("", Me)
If parrent="" Then
h.Download2("https://www.googleapis.com/drive/v3/files", _
Array As String("access_token", myAccessToken, _
"corpora", "user", _
"q","mimeType!='application/vnd.google-apps.folder' and" & _
"trashed=false"))
Else
h.Download2("https://www.googleapis.com/drive/v3/files", _
Array As String("access_token", myAccessToken, _
"corpora", "user", _
"q","mimeType!='application/vnd.google-apps.folder' and" & _
"'" & parrent & "' in parents and " & _
"trashed=false"))
End If
Wait For (h) JobDone(h As HttpJob)
If h.Success Then
Log(h.GetString)
Dim FilelisteExport As List
Dim Map1, fileEntry As Map
Dim J As JSONParser
Dim files As List
J.Initialize(h.GetString)
files.Initialize
Map1 = J.NextObject
files = Map1.Get("files")
If FilelisteExport.IsInitialized=False Then
FilelisteExport.Initialize
FilelisteExport.Clear
End If
For i = 0 To files.Size - 1
fileEntry = files.Get(i)
FilelisteExport.Add(fileEntry.Get("name") & ";" & fileEntry.Get("id"))
Next
CallSub2(evModule, evName & "_FileListResult", FilelisteExport)
End If
End Sub