Я использую ChilKat для разработки инструмента с использованием VB.NET, который выполняет загрузку одного файла в мою учетную запись на Google Диске. Я могу получить идентификатор папки в корневой папке, но мне не удается получить идентификатор папки, если есть путь к папкам.
В настоящий момент аргумент FolderPath не используется (я буду, когда узнаю, как правильно получить FolderID). На данный момент я могу получить идентификатор папки Nova, но ни одну из других папок в следующем дереве:
Есть ли более простой способ получить идентификатор папки из GoogleDrive? Я также хотел бы создать путь к папкам на Google Диске, если их не существует.
Я никогда не работал с JSON или HTTP-запросами, поэтому я как бы потерялся здесь. Любая помощь будет в основном оценена! Заранее спасибо!
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