Exports a Google Doc to the requested MIME type and returns the exported content. Please note that the exported content is limited to 10MB.
(Export only supports Google Docs) See https://developers.google.com/drive/v3/web/manage-downloads for a list of MIME types.
Dim rest As New Chilkat.Rest
Dim success As Boolean
' Provide a previously obtained OAuth2 access token.
Dim oauth2 As New Chilkat.OAuth2
oauth2.AccessToken = "OAUTH2_ACCESS_TOKEN"
rest.SetAuthOAuth2(oauth2)
success = Await rest.ConnectAsync("www.googleapis.com",443,True,True)
If (success <> True) Then
Debug.WriteLine(rest.LastErrorText)
Exit Sub
End If
rest.AddQueryParam("mimeType","application/pdf")
' First send the HTTP request.
success = Await rest.SendReqNoBodyAsync("GET","/drive/v3/files/1zvzpTHO1dM9vNKYxpmr4YrX7x_R6qiNGFb8WB8h9wuI/export")
If (success <> True) Then
Debug.WriteLine(rest.LastErrorText)
Exit Sub
End If
' Read the response header. If the response status code is success, stream to the file.
' Otherwise receive the error response text.
Dim statusCode As Integer = Await rest.ReadResponseHeaderAsync()
If (statusCode < 0) Then
Debug.WriteLine(rest.LastErrorText)
Exit Sub
End If
If (statusCode <> 200) Then
Debug.WriteLine("Received error response code: " & statusCode)
' Read the error response body.
Dim sbErrResponse As New Chilkat.StringBuilder
success = Await rest.ReadRespSbAsync(sbErrResponse)
If (success <> True) Then
Debug.WriteLine(rest.LastErrorText)
Exit Sub
End If
Debug.WriteLine("Error response:" & sbErrResponse.GetAsString())
Exit Sub
End If
' Stream the response body to the output file.
Dim respBodyStream As New Chilkat.Stream
respBodyStream.SinkFile = "/someDirectoryPath/test.pdf"
success = Await rest.ReadRespBodyStreamAsync(respBodyStream,True)
If (success <> True) Then
Debug.WriteLine(rest.LastErrorText)
Exit Sub
End If
Debug.WriteLine("Example Completed.")