# GoogleDriveClient

Dependency-light client for Google Drive metadata, content, collaboration, and change operations.

Class 

`OfficeIMO.GoogleWorkspace.Drive`

**Namespace**

`OfficeIMO.GoogleWorkspace.Drive`

**Assembly**

`OfficeIMO.GoogleWorkspace.Drive`

**Source revision**

`be6c300e4ab1` with working tree changes

**Source**

[GoogleDriveClient.cs:68](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.GoogleWorkspace.Drive/GoogleDriveClient.cs#L68)

**Implements**

`IDisposable`

**Modifiers**

sealed

Dependency-light client for Google Drive metadata, content, collaboration, and change operations.

## Inheritance

- object
- GoogleDriveClient

## Guides & Samples

Authored walkthroughs and practical samples linked to this API.

- [Manage Google Drive Files](/docs/google-workspace/drive/) Guide
  
  List, upload, download, copy, and share Google Drive files with the typed GoogleDriveClient from OfficeIMO.GoogleWorkspace.Drive.
- [Work with Google Shared Drives](/docs/google-workspace/shared-drives/) Guide
  
  Point exports at a shared drive and folder, check that the folder belongs to that drive, and track changes per shared drive.

## Usage

Explore 1 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

### Accepted by parameters 1

- Method [GoogleDriveTemporaryContentLease.CreatePublicReadLeaseAsync](/api/google-workspace-drive/officeimo-googleworkspace-drive-googledrivetemporarycontentlease/#method-createpublicreadleaseasync-officeimo-googleworkspace-drive-googledriveclient-byte-officeimo-googleworkspace-drive-googledriveuploadoptions-officeimo-googleworkspace-translationreport-threading-cancellationtoken) parameter `client`

Filter members 

Show inherited

## Constructors

`public GoogleDriveClient(GoogleWorkspaceSession session, GoogleDriveClientOptions? options = null)` [#](#constructor-ctor-officeimo-googleworkspace-googleworkspacesession-officeimo-googleworkspace-drive-googledriveclientoptions)

[GoogleDriveClient.cs:68](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.GoogleWorkspace.Drive/GoogleDriveClient.cs#L68)

Creates a Drive client bound to a Workspace session and a snapshot of client options.

Parameters

**session OfficeIMO.GoogleWorkspace.GoogleWorkspaceSession required**

**options OfficeIMO.GoogleWorkspace.Drive.GoogleDriveClientOptions? = null optional**

## Methods

`public async Task<GoogleDriveFile> CopyFileAsync(string fileId, string? name = null, string? parentId = null, TranslationReport? report = null, CancellationToken cancellationToken = default)` [#](#method-copyfileasync-string-string-string-officeimo-googleworkspace-translationreport-threading-cancellationtoken)

Copies a Drive file with an optional new name and parent.

Parameters

**fileId string required**

**name string? = null optional**

**parentId string? = null optional**

**report OfficeIMO.GoogleWorkspace.TranslationReport? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task<GoogleDriveFile>`

`public async Task<GoogleDriveComment> CreateCommentAsync(string fileId, string content, string? anchor = null, TranslationReport? report = null, CancellationToken cancellationToken = default)` [#](#method-createcommentasync-string-string-string-officeimo-googleworkspace-translationreport-threading-cancellationtoken)

Creates a Drive comment and reports the editor limitation for custom anchors.

Parameters

**fileId string required**

**content string required**

**anchor string? = null optional**

**report OfficeIMO.GoogleWorkspace.TranslationReport? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task<GoogleDriveComment>`

`public async Task<GoogleDriveFile> CreateFolderAsync(string name, string? parentId = null, TranslationReport? report = null, CancellationToken cancellationToken = default)` [#](#method-createfolderasync-string-string-officeimo-googleworkspace-translationreport-threading-cancellationtoken)

Creates a Drive folder, optionally under a parent folder.

Parameters

**name string required**

**parentId string? = null optional**

**report OfficeIMO.GoogleWorkspace.TranslationReport? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task<GoogleDriveFile>`

`public async Task<GoogleDrivePermission> CreatePermissionAsync(string fileId, GoogleDrivePermissionCreateOptions options, TranslationReport? report = null, CancellationToken cancellationToken = default)` [#](#method-createpermissionasync-string-officeimo-googleworkspace-drive-googledrivepermissioncreateoptions-officeimo-googleworkspace-translationreport-threading-cancellationtoken)

Creates a permission for a file or shared drive.

Parameters

**fileId string required**

**options OfficeIMO.GoogleWorkspace.Drive.GoogleDrivePermissionCreateOptions required**

**report OfficeIMO.GoogleWorkspace.TranslationReport? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task<GoogleDrivePermission>`

`public async Task<GoogleDriveReply> CreateReplyAsync(string fileId, string commentId, string content, string? action = null, TranslationReport? report = null, CancellationToken cancellationToken = default)` [#](#method-createreplyasync-string-string-string-string-officeimo-googleworkspace-translationreport-threading-cancellationtoken)

Creates a reply or applies an action such as resolving a comment thread.

Parameters

**fileId string required**

**commentId string required**

**content string required**

**action string? = null optional**

**report OfficeIMO.GoogleWorkspace.TranslationReport? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task<GoogleDriveReply>`

`public async Task DeleteCommentAsync(string fileId, string commentId, TranslationReport? report = null, CancellationToken cancellationToken = default)` [#](#method-deletecommentasync-string-string-officeimo-googleworkspace-translationreport-threading-cancellationtoken)

Deletes a Drive comment thread from a file.

Parameters

**fileId string required**

**commentId string required**

**report OfficeIMO.GoogleWorkspace.TranslationReport? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task`

`public async Task DeleteFileAsync(string fileId, TranslationReport? report = null, CancellationToken cancellationToken = default)` [#](#method-deletefileasync-string-officeimo-googleworkspace-translationreport-threading-cancellationtoken)

Permanently deletes a Drive file using guarded mutation policy.

Parameters

**fileId string required**

**report OfficeIMO.GoogleWorkspace.TranslationReport? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task`

`public async Task DeletePermissionAsync(string fileId, string permissionId, TranslationReport? report = null, CancellationToken cancellationToken = default)` [#](#method-deletepermissionasync-string-string-officeimo-googleworkspace-translationreport-threading-cancellationtoken)

Deletes a permission from a file or shared drive.

Parameters

**fileId string required**

**permissionId string required**

**report OfficeIMO.GoogleWorkspace.TranslationReport? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task`

`public async Task DeleteReplyAsync(string fileId, string commentId, string replyId, TranslationReport? report = null, CancellationToken cancellationToken = default)` [#](#method-deletereplyasync-string-string-string-officeimo-googleworkspace-translationreport-threading-cancellationtoken)

Deletes a reply from a Drive comment thread.

Parameters

**fileId string required**

**commentId string required**

**replyId string required**

**report OfficeIMO.GoogleWorkspace.TranslationReport? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task`

`public void Dispose()` [#](#method-dispose)

[GoogleDriveClient.cs:326](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.GoogleWorkspace.Drive/GoogleDriveClient.cs#L326)

Releases transport resources owned by the client.

`public async Task<byte[]> DownloadAsync(string fileId, IProgress<GoogleDriveTransferProgress>? progress = null, TranslationReport? report = null, CancellationToken cancellationToken = default, long? maxResponseBytes = null)` [#](#method-downloadasync-string-iprogress-officeimo-googleworkspace-drive-googledrivetransferprogress-officeimo-googleworkspace-translationreport-threading-cancellationtoken-nullable-system-int64)

Downloads binary file content into memory subject to the configured or per-call size limit.

Parameters

**fileId string required**

**progress System.IProgress<OfficeIMO.GoogleWorkspace.Drive.GoogleDriveTransferProgress>? = null optional**

**report OfficeIMO.GoogleWorkspace.TranslationReport? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

**maxResponseBytes long? = null optional**

Returns

`Task<byte[]>`

`public async Task<GoogleDriveDownloadCheckpoint> DownloadToFileAsync(string fileId, string destinationPath, GoogleDriveDownloadCheckpoint? checkpoint = null, Func<GoogleDriveDownloadCheckpoint, CancellationToken, Task>? checkpointSink = null, int chunkSize = 8388608, TranslationReport? report = null, CancellationToken cancellationToken = default)` [#](#member-1ba768ed1f1957bfdc1160bf)

Downloads to a new file or resumes an exact checkpoint after process restart.

Parameters

**fileId string required**

**destinationPath string required**

**checkpoint OfficeIMO.GoogleWorkspace.Drive.GoogleDriveDownloadCheckpoint? = null optional**

**checkpointSink System.Func<OfficeIMO.GoogleWorkspace.Drive.GoogleDriveDownloadCheckpoint, System.Threading.CancellationToken, System.Threading.Tasks.Task>? = null optional**

**chunkSize int = 8388608 optional**

**report OfficeIMO.GoogleWorkspace.TranslationReport? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task<GoogleDriveDownloadCheckpoint>`

`public async Task<byte[]> ExportAsync(string fileId, string mimeType, IProgress<GoogleDriveTransferProgress>? progress = null, TranslationReport? report = null, CancellationToken cancellationToken = default, long? maxResponseBytes = null)` [#](#method-exportasync-string-string-iprogress-officeimo-googleworkspace-drive-googledrivetransferprogress-officeimo-googleworkspace-translationreport-threading-cancellationtoken-nullable-system-int64)

Exports a Google-native file into memory using the requested MIME type and size limit.

Parameters

**fileId string required**

**mimeType string required**

**progress System.IProgress<OfficeIMO.GoogleWorkspace.Drive.GoogleDriveTransferProgress>? = null optional**

**report OfficeIMO.GoogleWorkspace.TranslationReport? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

**maxResponseBytes long? = null optional**

Returns

`Task<byte[]>`

`public async Task<GoogleDriveFile> GetFileAsync(string fileId, string? fields = null, TranslationReport? report = null, CancellationToken cancellationToken = default)` [#](#method-getfileasync-string-string-officeimo-googleworkspace-translationreport-threading-cancellationtoken)

Gets metadata for one Drive file using the default or caller-selected field projection.

Parameters

**fileId string required**

**fields string? = null optional**

**report OfficeIMO.GoogleWorkspace.TranslationReport? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task<GoogleDriveFile>`

`public async Task<GoogleDriveAboutFormats> GetFormatsAsync(TranslationReport? report = null, CancellationToken cancellationToken = default)` [#](#method-getformatsasync-officeimo-googleworkspace-translationreport-threading-cancellationtoken)

Gets the MIME formats Drive can import and export for the current account.

Parameters

**report OfficeIMO.GoogleWorkspace.TranslationReport? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task<GoogleDriveAboutFormats>`

`public static IReadOnlyList<string> GetRequiredScopes(GoogleDriveOperation operation)` [#](#method-getrequiredscopes-officeimo-googleworkspace-drive-googledriveoperation)

[GoogleDriveClient.cs:91](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.GoogleWorkspace.Drive/GoogleDriveClient.cs#L91)

Returns the default scope used by this client for a logical Drive operation.

Parameters

**operation OfficeIMO.GoogleWorkspace.Drive.GoogleDriveOperation required**

Returns

`IReadOnlyList<string>`

`public async Task<GoogleSharedDrive> GetSharedDriveAsync(string driveId, TranslationReport? report = null, CancellationToken cancellationToken = default)` [#](#method-getshareddriveasync-string-officeimo-googleworkspace-translationreport-threading-cancellationtoken)

Gets metadata and caller capabilities for a shared drive.

Parameters

**driveId string required**

**report OfficeIMO.GoogleWorkspace.TranslationReport? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task<GoogleSharedDrive>`

`public async Task<string> GetStartPageTokenAsync(string? driveId = null, TranslationReport? report = null, CancellationToken cancellationToken = default)` [#](#method-getstartpagetokenasync-string-officeimo-googleworkspace-translationreport-threading-cancellationtoken)

Gets a starting token for a user or shared-drive change feed.

Parameters

**driveId string? = null optional**

**report OfficeIMO.GoogleWorkspace.TranslationReport? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task<string>`

`public async Task<GoogleDriveChangeList> ListChangesAsync(string pageToken, GoogleDriveChangeListOptions? options = null, TranslationReport? report = null, CancellationToken cancellationToken = default)` [#](#method-listchangesasync-string-officeimo-googleworkspace-drive-googledrivechangelistoptions-officeimo-googleworkspace-translationreport-threading-cancellationtoken)

Reads one page from a Drive change feed and returns continuation state.

Parameters

**pageToken string required**

**options OfficeIMO.GoogleWorkspace.Drive.GoogleDriveChangeListOptions? = null optional**

**report OfficeIMO.GoogleWorkspace.TranslationReport? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task<GoogleDriveChangeList>`

`public async Task<GoogleDriveCommentList> ListCommentsAsync(string fileId, string? pageToken = null, TranslationReport? report = null, CancellationToken cancellationToken = default)` [#](#method-listcommentsasync-string-string-officeimo-googleworkspace-translationreport-threading-cancellationtoken)

Lists one page of comments, including deleted threads and replies.

Parameters

**fileId string required**

**pageToken string? = null optional**

**report OfficeIMO.GoogleWorkspace.TranslationReport? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task<GoogleDriveCommentList>`

`public async Task<GoogleDriveFileList> ListFilesAsync(GoogleDriveListOptions? options = null, TranslationReport? report = null, CancellationToken cancellationToken = default)` [#](#method-listfilesasync-officeimo-googleworkspace-drive-googledrivelistoptions-officeimo-googleworkspace-translationreport-threading-cancellationtoken)

Lists one page of Drive files using the requested query and corpus options.

Parameters

**options OfficeIMO.GoogleWorkspace.Drive.GoogleDriveListOptions? = null optional**

**report OfficeIMO.GoogleWorkspace.TranslationReport? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task<GoogleDriveFileList>`

`public async Task<GoogleDrivePermissionList> ListPermissionsAsync(string fileId, string? pageToken = null, int? pageSize = null, TranslationReport? report = null, CancellationToken cancellationToken = default)` [#](#method-listpermissionsasync-string-string-nullable-system-int32-officeimo-googleworkspace-translationreport-threading-cancellationtoken)

Lists one page of permissions for a file or shared drive.

Parameters

**fileId string required**

The file or shared-drive identifier.

**pageToken string? = null optional**

The continuation token returned by the previous page.

**pageSize int? = null optional**

The requested number of permissions. Google Drive caps this value at 100.

**report OfficeIMO.GoogleWorkspace.TranslationReport? = null optional**

An optional translation report that receives API diagnostics.

**cancellationToken System.Threading.CancellationToken = default optional**

A token that cancels the request.

Returns

`Task<GoogleDrivePermissionList>` The requested permission page and its continuation token, when another page exists.

`public async Task<GoogleDriveRevisionList> ListRevisionsAsync(string fileId, string? pageToken = null, TranslationReport? report = null, CancellationToken cancellationToken = default)` [#](#method-listrevisionsasync-string-string-officeimo-googleworkspace-translationreport-threading-cancellationtoken)

Lists one page of revision metadata for a Drive file.

Parameters

**fileId string required**

**pageToken string? = null optional**

**report OfficeIMO.GoogleWorkspace.TranslationReport? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task<GoogleDriveRevisionList>`

`public async Task<GoogleDriveFile> MoveFileAsync(string fileId, string folderId, TranslationReport? report = null, CancellationToken cancellationToken = default)` [#](#method-movefileasync-string-string-officeimo-googleworkspace-translationreport-threading-cancellationtoken)

Moves a file to one folder, removing its existing parents when necessary.

Parameters

**fileId string required**

**folderId string required**

**report OfficeIMO.GoogleWorkspace.TranslationReport? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task<GoogleDriveFile>`

`public async Task<GoogleDriveFile> ResolveFolderAsync(string folderId, string? expectedDriveId = null, TranslationReport? report = null, CancellationToken cancellationToken = default)` [#](#method-resolvefolderasync-string-string-officeimo-googleworkspace-translationreport-threading-cancellationtoken)

Gets a folder and verifies its type and, when supplied, containing shared drive.

Parameters

**folderId string required**

**expectedDriveId string? = null optional**

**report OfficeIMO.GoogleWorkspace.TranslationReport? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task<GoogleDriveFile>`

`public async Task<GoogleDriveFile> UploadMultipartAsync(byte[] content, GoogleDriveUploadOptions options, TranslationReport? report = null, CancellationToken cancellationToken = default)` [#](#method-uploadmultipartasync-byte-officeimo-googleworkspace-drive-googledriveuploadoptions-officeimo-googleworkspace-translationreport-threading-cancellationtoken)

Uploads content of at most 5 MiB in one multipart request.

Parameters

**content byte[] required**

**options OfficeIMO.GoogleWorkspace.Drive.GoogleDriveUploadOptions required**

**report OfficeIMO.GoogleWorkspace.TranslationReport? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task<GoogleDriveFile>` Metadata for the created Drive file.

`public async Task<GoogleDriveFile> UploadResumableAsync(byte[] content, GoogleDriveUploadOptions options, TranslationReport? report = null, CancellationToken cancellationToken = default)` [#](#method-uploadresumableasync-byte-officeimo-googleworkspace-drive-googledriveuploadoptions-officeimo-googleworkspace-translationreport-threading-cancellationtoken)

Uploads in aligned resumable chunks and reconciles ambiguous chunk responses with the server session.

Parameters

**content byte[] required**

**options OfficeIMO.GoogleWorkspace.Drive.GoogleDriveUploadOptions required**

**report OfficeIMO.GoogleWorkspace.TranslationReport? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task<GoogleDriveFile>` Metadata for the created Drive file.

`public async Task<GoogleDriveResumableUploadResult> UploadResumableFileAsync(string path, GoogleDriveUploadOptions options, GoogleDriveResumableUploadCheckpoint? checkpoint = null, Func<GoogleDriveResumableUploadCheckpoint, CancellationToken, Task>? checkpointSink = null, TranslationReport? report = null, CancellationToken cancellationToken = default)` [#](#member-ea1643e539a309a437083add)

Uploads a file through the durable resumable path.

Parameters

**path string required**

**options OfficeIMO.GoogleWorkspace.Drive.GoogleDriveUploadOptions required**

**checkpoint OfficeIMO.GoogleWorkspace.Drive.GoogleDriveResumableUploadCheckpoint? = null optional**

**checkpointSink System.Func<OfficeIMO.GoogleWorkspace.Drive.GoogleDriveResumableUploadCheckpoint, System.Threading.CancellationToken, System.Threading.Tasks.Task>? = null optional**

**report OfficeIMO.GoogleWorkspace.TranslationReport? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task<GoogleDriveResumableUploadResult>`

`public async Task<GoogleDriveResumableUploadResult> UploadResumableStreamAsync(Stream content, long length, GoogleDriveUploadOptions options, GoogleDriveResumableUploadCheckpoint? checkpoint = null, Func<GoogleDriveResumableUploadCheckpoint, CancellationToken, Task>? checkpointSink = null, TranslationReport? report = null, CancellationToken cancellationToken = default)` [#](#member-fad752465cd782890b8b505b)

Uploads a seekable stream and persists progress after initiation and every confirmed chunk.

Parameters

**content System.IO.Stream required**

**length long required**

**options OfficeIMO.GoogleWorkspace.Drive.GoogleDriveUploadOptions required**

**checkpoint OfficeIMO.GoogleWorkspace.Drive.GoogleDriveResumableUploadCheckpoint? = null optional**

**checkpointSink System.Func<OfficeIMO.GoogleWorkspace.Drive.GoogleDriveResumableUploadCheckpoint, System.Threading.CancellationToken, System.Threading.Tasks.Task>? = null optional**

**report OfficeIMO.GoogleWorkspace.TranslationReport? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task<GoogleDriveResumableUploadResult>`

## Inherited Methods

`public virtual bool Equals(object? obj)` [#](#method-equals-object)

Inherited from object

Parameters

**obj object? required**

Returns

`bool`

`public virtual int GetHashCode()` [#](#method-gethashcode)

Inherited from object

Returns

`int`

`public Type GetType()` [#](#method-gettype)

Inherited from object

Returns

`Type`

`public virtual string? ToString()` [#](#method-tostring)

Inherited from object

Returns

`string?`

## Fields

`public const string DefaultFileFields` [#](#field-defaultfilefields)

[GoogleDriveClient.cs:60](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.GoogleWorkspace.Drive/GoogleDriveClient.cs#L60)

Default Drive fields requested for file metadata.

Value: `id,name,mimeType,driveId,parents,webViewLink,webContentLink,modifiedTime,createdTime,version,size,trashed,capabilities(canDownload,canEdit,canMoveItemWithinDrive,canMoveItemOutOfDrive,canDelete,canShare,canComment)`

<!-- PowerForge markdown artifact sha256:E3073615F33218BD35BC2C03BC2F30A8ACA338D343B43FA45451B1F583BF075C -->
