none
Google Drive Upload using VB.Net RRS feed

All replies

  • From my experience (and I can be wrong), the best way to work with Google would be with the NuGet package. Although the following is in C# it's not difficult to convert to VB.NET 

    https://developers.google.com/drive/api/v3/quickstart/dotnet

    Option Infer On
    
    ' Copyright 2018 Google LLC
    '
    ' Licensed under the Apache License, Version 2.0 (the "License");
    ' you may not use this file except in compliance with the License.
    ' You may obtain a copy of the License at
    '
    '     http://www.apache.org/licenses/LICENSE-2.0
    '
    ' Unless required by applicable law or agreed to in writing, software
    ' distributed under the License is distributed on an "AS IS" BASIS,
    ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    ' See the License for the specific language governing permissions and
    ' limitations under the License.
    
    ' [START drive_quickstart]
    Imports Google.Apis.Auth.OAuth2
    Imports Google.Apis.Drive.v3
    Imports Google.Apis.Drive.v3.Data
    Imports Google.Apis.Services
    Imports Google.Apis.Util.Store
    Imports System
    Imports System.Collections.Generic
    Imports System.IO
    Imports System.Linq
    Imports System.Text
    Imports System.Threading
    Imports System.Threading.Tasks
    
    Namespace DriveQuickstart
    	Friend Class Program
    		' If modifying these scopes, delete your previously saved credentials
    		' at ~/.credentials/drive-dotnet-quickstart.json
    		Private Shared Scopes() As String = { DriveService.Scope.DriveReadonly }
    		Private Shared ApplicationName As String = "Drive API .NET Quickstart"
    
    		Shared Sub Main(ByVal args() As String)
    			Dim credential As UserCredential
    
    			Using stream = New FileStream("credentials.json", FileMode.Open, FileAccess.Read)
    				' The file token.json stores the user's access and refresh tokens, and is created
    				' automatically when the authorization flow completes for the first time.
    				Dim credPath As String = "token.json"
    				credential = GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(stream).Secrets, Scopes, "user", CancellationToken.None, New FileDataStore(credPath, True)).Result
    				Console.WriteLine("Credential file saved to: " & credPath)
    			End Using
    
    			' Create Drive API service.
    			Dim service = New DriveService(New BaseClientService.Initializer() With { _
    				.HttpClientInitializer = credential, _
    				.ApplicationName = ApplicationName _
    			})
    
    			' Define parameters of request.
    			Dim listRequest As FilesResource.ListRequest = service.Files.List()
    			listRequest.PageSize = 10
    			listRequest.Fields = "nextPageToken, files(id, name)"
    
    			' List files.
    			Dim files As IList(Of Google.Apis.Drive.v3.Data.File) = listRequest.Execute().Files
    			Console.WriteLine("Files:")
    			If files IsNot Nothing AndAlso files.Count > 0 Then
    				For Each file In files
    					Console.WriteLine("{0} ({1})", file.Name, file.Id)
    				Next
    			Else
    				Console.WriteLine("No files found.")
    			End If
    			Console.Read()
    
    		End Sub
    	End Class
    End Namespace
    ' [END drive_quickstart]
    


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Wednesday, March 4, 2020 11:35 AM
    Moderator
  • Thanks for reply.

    Can you please confirm if the following is even possible or not, so don't try to do which is not supported.

    Is it possible to create a portable solution (destination PC should not require to install APIs etc.) to upload file(s) to Google Drive silently without user intervention? 

    Wednesday, March 4, 2020 11:50 AM
  • Thanks for reply.

    Can you please confirm if the following is even possible or not, so don't try to do which is not supported.

    Is it possible to create a portable solution (destination PC should not require to install APIs etc.) to upload file(s) to Google Drive silently without user intervention? 

    It's not possible as I indicated by indicating you need to NuGet package.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Wednesday, March 4, 2020 12:24 PM
    Moderator
  • Can you please confirm if the following is even possible or not, so don't try to do which is not supported.

    Is it possible to create a portable solution (destination PC should not require to install APIs etc.) to upload file(s) to Google Drive silently without user intervention? 

    It is possible (I did it in C++ with native WinHTTP APIs) 

    but complicated (mainly the authentication)

    It is simpler to use packages/wrappers

    Wednesday, March 4, 2020 12:36 PM
  • Can you please confirm if the following is even possible or not, so don't try to do which is not supported.

    Is it possible to create a portable solution (destination PC should not require to install APIs etc.) to upload file(s) to Google Drive silently without user intervention? 

    It is possible (I did it in C++ with native WinHTTP APIs) 

    but complicated (mainly the authentication)

    It is simpler to use packages/wrappers

    Is that simple - straight forward with OneDrive? 
    Wednesday, March 4, 2020 3:20 PM

  • Is that simple - straight forward with OneDrive? 

    It was simpler (I used it on a Freeware)... but still complicated

    (by sending HTTP requests to login.live.com to get access and refresh tokens )

    Wednesday, March 4, 2020 3:37 PM