Table of Contents

Class Files

Namespace
Google.GenAI
Assembly
Google.GenAI.dll
public sealed class Files
Inheritance
Files
Inherited Members
Extension Methods

Constructors

Files(ApiClient)

public Files(ApiClient apiClient)

Parameters

apiClient ApiClient

Methods

DeleteAsync(string, DeleteFileConfig?, CancellationToken)

public Task<DeleteFileResponse> DeleteAsync(string name, DeleteFileConfig? config = null, CancellationToken cancellationToken = default)

Parameters

name string
config DeleteFileConfig
cancellationToken CancellationToken

Returns

Task<DeleteFileResponse>

DownloadAsync(File, DownloadFileConfig?, CancellationToken)

Downloads a File object and returns it as a Stream. Caller is responsible for disposing the returned stream.

public Task<Stream> DownloadAsync(File file, DownloadFileConfig? config = null, CancellationToken cancellationToken = default)

Parameters

file File

The File object to download.

config DownloadFileConfig

A DownloadFileConfig instance that specifies the optional configurations.

cancellationToken CancellationToken

A CancellationToken to cancel the operation.

Returns

Task<Stream>

A Task<TResult> that represents the asynchronous operation. The task result contains a Stream with the file data.

DownloadAsync(GeneratedVideo, DownloadFileConfig?, CancellationToken)

Downloads a GeneratedVideo object and returns it as a Stream. Caller is responsible for disposing the returned stream.

public Task<Stream> DownloadAsync(GeneratedVideo generatedVideo, DownloadFileConfig? config = null, CancellationToken cancellationToken = default)

Parameters

generatedVideo GeneratedVideo

The GeneratedVideo object to download.

config DownloadFileConfig

A DownloadFileConfig instance that specifies the optional configurations.

cancellationToken CancellationToken

A CancellationToken to cancel the operation.

Returns

Task<Stream>

A Task<TResult> that represents the asynchronous operation. The task result contains a Stream with the file data.

DownloadAsync(Video, DownloadFileConfig?, CancellationToken)

Downloads a Video object and returns it as a Stream. Caller is responsible for disposing the returned stream.

public Task<Stream> DownloadAsync(Video video, DownloadFileConfig? config = null, CancellationToken cancellationToken = default)

Parameters

video Video

The Video object to download.

config DownloadFileConfig

A DownloadFileConfig instance that specifies the optional configurations.

cancellationToken CancellationToken

A CancellationToken to cancel the operation.

Returns

Task<Stream>

A Task<TResult> that represents the asynchronous operation. The task result contains a Stream with the file data.

DownloadAsync(string, DownloadFileConfig?, CancellationToken)

Downloads a file and returns it as a Stream. Caller is responsible for disposing the returned stream.

public Task<Stream> DownloadAsync(string fileName, DownloadFileConfig? config = null, CancellationToken cancellationToken = default)

Parameters

fileName string

The name of the file to download (e.g., "files/abc123" or "abc123").

config DownloadFileConfig

A DownloadFileConfig instance that specifies the optional configurations.

cancellationToken CancellationToken

A CancellationToken to cancel the operation.

Returns

Task<Stream>

A Task<TResult> that represents the asynchronous operation. The task result contains a Stream with the file data.

DownloadToFileAsync(File, string, DownloadFileConfig?, CancellationToken)

Downloads a File object directly to a file path.

public Task DownloadToFileAsync(File file, string outputPath, DownloadFileConfig? config = null, CancellationToken cancellationToken = default)

Parameters

file File

The File object to download.

outputPath string

The path where the file should be saved.

config DownloadFileConfig

A DownloadFileConfig instance that specifies the optional configurations.

cancellationToken CancellationToken

A CancellationToken to cancel the operation.

Returns

Task

A Task that represents the asynchronous operation.

DownloadToFileAsync(GeneratedVideo, string, DownloadFileConfig?, CancellationToken)

Downloads a GeneratedVideo object directly to a file path.

public Task DownloadToFileAsync(GeneratedVideo generatedVideo, string outputPath, DownloadFileConfig? config = null, CancellationToken cancellationToken = default)

Parameters

generatedVideo GeneratedVideo

The GeneratedVideo object to download.

outputPath string

The path where the Video should be saved.

config DownloadFileConfig

A DownloadFileConfig instance that specifies the optional configurations.

cancellationToken CancellationToken

A CancellationToken to cancel the operation.

Returns

Task

A Task that represents the asynchronous operation.

DownloadToFileAsync(Video, string, DownloadFileConfig?, CancellationToken)

Downloads a Video object directly to a file path.

public Task DownloadToFileAsync(Video video, string outputPath, DownloadFileConfig? config = null, CancellationToken cancellationToken = default)

Parameters

video Video

The Video object to download.

outputPath string

The path where the Video should be saved.

config DownloadFileConfig

A DownloadFileConfig instance that specifies the optional configurations.

cancellationToken CancellationToken

A CancellationToken to cancel the operation.

Returns

Task

A Task that represents the asynchronous operation.

DownloadToFileAsync(string, string, DownloadFileConfig?, CancellationToken)

Downloads a file directly to a file path.

public Task DownloadToFileAsync(string fileName, string outputPath, DownloadFileConfig? config = null, CancellationToken cancellationToken = default)

Parameters

fileName string

The name of the file to download (e.g., "files/abc123" or "abc123").

outputPath string

The path where the file should be saved.

config DownloadFileConfig

A DownloadFileConfig instance that specifies the optional configurations.

cancellationToken CancellationToken

A CancellationToken to cancel the operation.

Returns

Task

A Task that represents the asynchronous operation.

GetAsync(string, GetFileConfig?, CancellationToken)

public Task<File> GetAsync(string name, GetFileConfig? config = null, CancellationToken cancellationToken = default)

Parameters

name string
config GetFileConfig
cancellationToken CancellationToken

Returns

Task<File>

ListAsync(ListFilesConfig?, CancellationToken)

public Task<Pager<File, ListFilesConfig, ListFilesResponse>> ListAsync(ListFilesConfig? config = null, CancellationToken cancellationToken = default)

Parameters

config ListFilesConfig
cancellationToken CancellationToken

Returns

Task<Pager<File, ListFilesConfig, ListFilesResponse>>

RegisterFilesAsync(IEnumerable<string>, GoogleCredential, RegisterFilesConfig?, CancellationToken)

Registers Google Cloud Storage files for use with the API.

public Task<RegisterFilesResponse> RegisterFilesAsync(IEnumerable<string> uris, GoogleCredential credential, RegisterFilesConfig? config = null, CancellationToken cancellationToken = default)

Parameters

uris IEnumerable<string>

The list of GCS URIs to register.

credential GoogleCredential

The GoogleCredential to use for authorization.

config RegisterFilesConfig

A RegisterFilesConfig instance that specifies the optional configurations.

cancellationToken CancellationToken

A CancellationToken to cancel the operation.

Returns

Task<RegisterFilesResponse>

A Task<TResult> that represents the asynchronous operation. The task result contains the RegisterFilesResponse.

UploadAsync(byte[], string?, UploadFileConfig?, CancellationToken)

Uploads a file from a byte array.

public Task<File> UploadAsync(byte[] bytes, string? fileName = null, UploadFileConfig? config = null, CancellationToken cancellationToken = default)

Parameters

bytes byte[]

The file content as a byte array.

fileName string

Optional file name to use.

config UploadFileConfig

A UploadFileConfig instance that specifies the optional configurations.

cancellationToken CancellationToken

A CancellationToken to cancel the operation.

Returns

Task<File>

A Task<TResult> that represents the asynchronous operation. The task result contains the uploaded File metadata.

UploadAsync(Stream, long, string?, string?, UploadFileConfig?, CancellationToken)

Uploads a file from a stream.

public Task<File> UploadAsync(Stream stream, long size, string? fileName = null, string? mimeType = null, UploadFileConfig? config = null, CancellationToken cancellationToken = default)

Parameters

stream Stream

The stream containing the file data.

size long

The size of the file in bytes.

fileName string

Optional file name to use.

mimeType string

Optional MIME type. If not provided, defaults to application/octet-stream.

config UploadFileConfig

A UploadFileConfig instance that specifies the optional configurations.

cancellationToken CancellationToken

A CancellationToken to cancel the operation.

Returns

Task<File>

A Task<TResult> that represents the asynchronous operation. The task result contains the uploaded File metadata.

UploadAsync(string, UploadFileConfig?, CancellationToken)

Uploads a file from a file path.

public Task<File> UploadAsync(string filePath, UploadFileConfig? config = null, CancellationToken cancellationToken = default)

Parameters

filePath string

The path to the file to upload.

config UploadFileConfig

A UploadFileConfig instance that specifies the optional configurations.

cancellationToken CancellationToken

A CancellationToken to cancel the operation.

Returns

Task<File>

A Task<TResult> that represents the asynchronous operation. The task result contains the uploaded File metadata.