Im using the ChilKat to develop a tool using VB.NET, that performs a single file upload to my google drive account.
Im able to get the folderID within a root folder, but im struggling to get the folderID if there is a path of folders.
At this moment the argument FolderPath is not being used (i will, when i uncover how to properly get the FolderID). For now, i can get the "Nova" folder id, but none of the other folders within the following tree:
Is there an easier way to get the folderID from GoogleDrive?
I would also like to create the path of folders on Google Drive, in case they dont exist.
I never worked with JSON or HTTP requests, so im kind of lost here.
Any help would be mostly appreciated!
Thanks in advance!
Private Function FolderID(ByVal FolderPath As String) As String
Dim rest As New Chilkat.Rest
' Connect using TLS.
Dim success As Boolean = rest.Connect("www.googleapis.com", 443, True, True)
' Provide the authentication credentials (i.e. the access token)
Dim gAuth As New Chilkat.AuthGoogle
gAuth.AccessToken = M_AccessToken
rest.SetAuthGoogle(gAuth)
Dim json As New Chilkat.JsonObject
json.EmitCompact = False
' Get the folder Testes folder that is in the Google Drive root.
rest.AddQueryParam("q", "'root' in parents and name='Testes'")
Dim jsonResponse As String = rest.FullRequestNoBody("GET", "/drive/v3/files")
If Not rest.LastMethodSuccess Then
Return rest.LastErrorText
Exit Function
End If
json.Load(jsonResponse)
rest.ClearAllQueryParams()
' Now that we know the ID for the Testes directory, get the id for the folder Nova having Testes as the parent.
Dim sbQuery As New Chilkat.StringBuilder
sbQuery.Append("name = 'nova' and '")
sbQuery.Append(json.StringOf("files[0].id"))
sbQuery.Append("' in parents")
rest.AddQueryParamSb("q", sbQuery)
jsonResponse = rest.FullRequestNoBody("GET", "/drive/v3/files")
If Not rest.LastMethodSuccess Then
Return (rest.LastErrorText)
Exit Function
End If
json.Load(jsonResponse)
Return json.StringOf("files[0].id")
End Function
question from:
https://stackoverflow.com/questions/65862352/how-to-get-the-folderid-from-google-drive-folders-using-chilkat-dll 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…