Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

GoogleDriveClient

OfficeIMO.GoogleWorkspace.Drive

Namespace
OfficeIMO.GoogleWorkspace.Drive
Assembly
OfficeIMO.GoogleWorkspace.Drive
Source revision
be6c300e4ab1 with working tree changes
Implements
IDisposable
Modifiers
sealed

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

Inheritance

  • object
  • GoogleDriveClient

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

Constructors

public GoogleDriveClient(GoogleWorkspaceSession session, GoogleDriveClientOptions? options = null) #

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) #

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) #

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) #

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) #

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
public async Task<GoogleDriveReply> CreateReplyAsync(string fileId, string commentId, string content, string? action = null, TranslationReport? report = null, CancellationToken cancellationToken = default) #

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) #

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) #

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) #

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) #

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() #

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) #

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) #

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
public async Task<byte[]> ExportAsync(string fileId, string mimeType, IProgress<GoogleDriveTransferProgress>? progress = null, TranslationReport? report = null, CancellationToken cancellationToken = default, long? maxResponseBytes = null) #

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) #

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) #

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
public static IReadOnlyList<string> GetRequiredScopes(GoogleDriveOperation operation) #

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) #

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) #

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) #

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
public async Task<GoogleDriveCommentList> ListCommentsAsync(string fileId, string? pageToken = null, TranslationReport? report = null, CancellationToken cancellationToken = default) #

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
public async Task<GoogleDriveFileList> ListFilesAsync(GoogleDriveListOptions? options = null, TranslationReport? report = null, CancellationToken cancellationToken = default) #

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) #

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) #

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
public async Task<GoogleDriveFile> MoveFileAsync(string fileId, string folderId, TranslationReport? report = null, CancellationToken cancellationToken = default) #

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) #

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) #

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) #

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) #

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
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) #

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

Fields

public const string DefaultFileFields #

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)