Geminix.V1beta.File (geminix v0.2.0)

A file uploaded to the API. Next ID: 15

Fields:

  • :create_time (DateTime.t/0) - Output only. The timestamp of when the File was created.
  • :display_name (binary/0) - 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"
  • :download_uri (binary/0) - Output only. The download uri of the File.
  • :error (Geminix.V1beta.Status.t/0) - Output only. Error status if File processing failed.
  • :expiration_time (DateTime.t/0) - Output only. The timestamp of when the File will be deleted. Only set if the File is scheduled to expire.
  • :mime_type (binary/0) - Output only. MIME type of the file.
  • :name (binary/0) - Immutable. Identifier. 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
  • :sha256_hash (binary/0) - Output only. SHA-256 hash of the uploaded bytes.
  • :size_bytes (binary/0) - Output only. Size of the file in bytes.
  • :source (binary/0) - Source of the File.
  • :state (binary/0) - Output only. Processing state of the File.
  • :update_time (DateTime.t/0) - Output only. The timestamp of when the File was last updated.
  • :uri (binary/0) - Output only. The uri of the File.
  • :video_metadata (Geminix.V1beta.VideoFileMetadata.t/0) - Output only. Metadata for a video.

Summary

Functions

Create a Geminix.V1beta.File.t/0 from a map returned by the Gemini API.

Extract the MIME type from the file path by inspecting the file extension or the file contents.

Upload a file from a local path.

Types

t()

@type t() :: %Geminix.V1beta.File{
  __meta__: term(),
  create_time: DateTime.t(),
  display_name: binary(),
  download_uri: binary(),
  error: Geminix.V1beta.Status.t(),
  expiration_time: DateTime.t(),
  mime_type: binary(),
  name: binary(),
  sha256_hash: binary(),
  size_bytes: binary(),
  source: binary(),
  state: binary(),
  update_time: DateTime.t(),
  uri: binary(),
  video_metadata: Geminix.V1beta.VideoFileMetadata.t()
}

Functions

from_map(schema \\ %__MODULE__{}, map)

@spec from_map(t(), map()) :: {:ok, t()} | {:error, Ecto.Changeset.t()}

Create a Geminix.V1beta.File.t/0 from a map returned by the Gemini API.

Sometimes, this function should not be applied to the full response body, but instead it should be applied to the correct part of the map in the response body. This depends on the concrete API call.

mime_type(local_path)

@spec mime_type(Path.t()) :: binary()

Extract the MIME type from the file path by inspecting the file extension or the file contents.

upload(local_path, opts \\ [])

@spec upload(
  Path.t(),
  keyword()
) ::
  {:ok, t()}
  | {:error, {:invalid_data, Ecto.Changeset.t()}}
  | {:error, {:bad_response, Req.Response.t()}}

Upload a file from a local path.