Google Drive API: Uploading, Viewing, Downloading & Deleting Files

Опубликовано: 04 Октябрь 2024
на канале: Everyday Be Coding
65,007
454

Cloud Storage Access through API - ASP.NET MVC 5 - C# (Part-2)

Blog: https://everyday-be-coding.blogspot.c...
Twitter :   / everydaycoding  
Facebook:   / everydaybecoding  

Google Drive API v3 - a) File Uploading,
b) Viewing
c) Downloading &
d) Deleting

Suggested video link:    • Google Drive API v3 - Enable & Get Cl...  
Source Code: https://goo.gl/E6mTJD

A) Attach client secret JSON file:
Please copy this downloaded client_secret.json file & paste into any path of your hard disk:
In my case: D:\

Now, Go to the Visual Studio 2013 or Higher version:

Step 1: First Create an Empty MVC Project. Name of the project: GoogleDriveRestAPI_v3
Step 2: Opening the NuGet Package Manager Console, Select the package source and run this command.

install-package Google.Apis.Drive.v3

Step 3 (Model):
Create a model class (Name: GoogleDriveFiles.cs) under the Model folder of project solution.

B) Drive Access Permission Scope of Application:
Here, we need to get permission to our application.

DriveService.Scope.Drive: View and manage the files in your Google Drive.
DriveService.Scope.DriveAppdata: View and manage its own configuration data in your Google Drive.
DriveService.Scope.DriveFile: View and manage google drive files and folders that you are open and created with this app.

DriveService.Scope.DriveMetadata: View and manage metadata of files in your Google Drive
DriveService.Scope.Drive.MetadataReadonly: View metadata of files in your Google Drive.
DriveService.Scope.Drive.PhotosReadonly: views the photos, videos, albums in your Google Photos.
DriveService.Scope.Drive.ReadOnly: View the files in your Google Drive.
DriveService.Scope.DriveScripts: Modify your Google apps Scripts script behavior.

Step 4 (Repository):
After that, create an another class (Name: GoogleDriveFilesRepository.cs) under this same Model folder.
Step 5 (Controller): Add a controller class (HomeController.cs) under this controller folder.

Step 6 (View): Add a View (View Name: GetGoogleDriveFiles.cshtml) of GetGoogleDriveFiles action method.

#EverydayBeCoding
Thank you for watching this video.
Please subscribe my YouTube Channel & don't forget to like and share.