Skip to main content
A newer version of this page is available. .

Google Drive File System Provider

  • 2 minutes to read

The Google Drive file system provider (GoogleDriveFileSystemProvider) allows you to connect the ASPxFileManager to Google Drive.

Prerequisites

Register the Google Drive service account that is linked to your application. The service account allows you to use the Google APIs to access a user’s account without client-side authorization.

Configure Google Drive Service Account

Follow the steps below to configure your Google Drive service account.

  1. Open the Service accounts page and click Create.

  1. In the New Project window, enter the project name and click Create.

  1. Open the Google API Console page to obtain the service account’s credentials. Click Enable APIs and Services to access the Google Drive API.

  1. Enable Google Drive API.

  1. In the Credentials section, select Create credentials and then select Service account key from the drop-down menu.

  1. Click Create to create the service account key in JSON format and save the .json file to your computer.

  1. Open the downloaded JSON file and get credentials from it.

Private key:

Client Email:

...
AccountManager.RegisterGoogleDrive("Google", "my-test-project@my-test-project-235211.iam.gserviceaccount.com", 
"DANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCu6OragV1n…...");

Provider Settings

Set the ASPxFileManager.ProviderType property to FileManagerProviderType.GoogleDrive to allow the ASPxFileManager to manage files and folders in Google Drive.

The GoogleDriveFileSystemProvider class allows you to access files’ and folders’ hierarchy and manipulate these files in the file manager.

ASPxFileManager_GoogleDriveFileSystemProvider

Do the following to connect the ASPxFileManager to Google Drive:

  • Use the AccountManager.RegisterGoogleDrive method to register the Google Drive account in the global.asax file.

    Note

    Use the credetials.json file (Google Drive creates this file when you register the service account) to get the clientId and privateKey parameters for the AccountManager.RegisterGoogleDrive method.

    AccountManager.RegisterGoogleDrive("FileManagerGoogleDriveAccount", "custom-service-account@api-project-82456107.iam.gserviceaccount.com", "..MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCVoaYrE7fEgu...");
    
  • Use the ASPxFileManager.SettingsGoogleDrive property to specify the Google Drive account’s name (FileManagerGoogleDriveProviderSettings.AccountName).

    <dx:ASPxFileManager ID="FileManager" runat="server" ProviderType="GoogleDrive">
        <SettingsGoogleDrive AccountName="FileManagerGoogleDriveAccount" />
        ...
    </dx:ASPxFileManager>
    

The ASPxFileManager allows you to handle every request to Google Drive (the ASPxFileManager.CloudProviderRequest event).

Online Demo

File Manager - Google Drive Provider