Skip to main content
Retrieves the metadata and status of a previously uploaded file.

Method Signature

Parameters

string
required
The file resource name to retrieve.Format: "files/abc123" or just "abc123"The name is returned when you upload a file using files.upload().
GetFileConfig
Optional configuration for the request.Available options:
  • http_options: Custom HTTP request options

Returns

File
A File object containing:
  • name: The resource name
  • uri: The URI to use in API calls
  • display_name: Human-readable name
  • mime_type: File MIME type
  • size_bytes: File size
  • create_time: Upload timestamp
  • update_time: Last update timestamp
  • expiration_time: When the file expires
  • state: Current state (PROCESSING, ACTIVE, or FAILED)
  • sha256_hash: SHA-256 hash of the file

Examples

Get File by Name

Check File Processing Status

Get File with Short Name

Use Retrieved File in Prompt

Get File Details After Upload

Async Get

Verify File Before Using

Check Multiple Files

File States

Files can be in three states:
  • PROCESSING: File is being processed (e.g., video encoding)
  • ACTIVE: File is ready to use in API calls
  • FAILED: File processing failed

Error Handling

API Availability

This method is only available in the Gemini API (not Vertex AI).