Table of Contents

Class File

Namespace
Google.GenAI.Types
Assembly
Google.GenAI.dll

A file uploaded to the API.

public record File : IEquatable<File>
Inheritance
File
Implements
Inherited Members

Properties

CreateTime

Output only. The timestamp of when the File was created.

[JsonPropertyName("createTime")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public DateTime? CreateTime { get; set; }

Property Value

DateTime?

DisplayName

Optional. The human-readable display name for the File. The display name must be no more than 512 characters in length, including spaces. Example: 'Welcome Image'

[JsonPropertyName("displayName")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? DisplayName { get; set; }

Property Value

string

DownloadUri

Output only. The URI of the File, only set for downloadable (generated) files.

[JsonPropertyName("downloadUri")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? DownloadUri { get; set; }

Property Value

string

Error

Output only. Error status if File processing failed.

[JsonPropertyName("error")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public FileStatus? Error { get; set; }

Property Value

FileStatus

ExpirationTime

Output only. The timestamp of when the File will be deleted. Only set if the File is scheduled to expire.

[JsonPropertyName("expirationTime")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public DateTime? ExpirationTime { get; set; }

Property Value

DateTime?

MimeType

Output only. MIME type of the file.

[JsonPropertyName("mimeType")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? MimeType { get; set; }

Property Value

string

Name

The File resource name. The ID (name excluding the "files/" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be generated. Example: files/123-456

[JsonPropertyName("name")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Name { get; set; }

Property Value

string

Sha256Hash

Output only. SHA-256 hash of the uploaded bytes. The hash value is encoded in base64 format.

[JsonPropertyName("sha256Hash")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Sha256Hash { get; set; }

Property Value

string

SizeBytes

Output only. Size of the file in bytes.

[JsonPropertyName("sizeBytes")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonConverter(typeof(StringToNullableLongConverter))]
public long? SizeBytes { get; set; }

Property Value

long?

Source

Output only. The source of the File.

[JsonPropertyName("source")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public FileSource? Source { get; set; }

Property Value

FileSource?

State

Output only. Processing state of the File.

[JsonPropertyName("state")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public FileState? State { get; set; }

Property Value

FileState?

UpdateTime

Output only. The timestamp of when the File was last updated.

[JsonPropertyName("updateTime")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public DateTime? UpdateTime { get; set; }

Property Value

DateTime?

Uri

Output only. The URI of the File.

[JsonPropertyName("uri")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Uri { get; set; }

Property Value

string

VideoMetadata

Output only. Metadata for a video.

[JsonPropertyName("videoMetadata")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public Dictionary<string, object>? VideoMetadata { get; set; }

Property Value

Dictionary<string, object>

Methods

FromJson(string, JsonSerializerOptions?)

Deserializes a JSON string to a File object.

public static File? FromJson(string jsonString, JsonSerializerOptions? options = null)

Parameters

jsonString string

The JSON string to deserialize.

options JsonSerializerOptions

Optional JsonSerializerOptions.

Returns

File

The deserialized File object, or null if deserialization fails.