# `LangChain.FileUploader.FileGoogle`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.4/lib/file_uploaders/file_google.ex#L1)

Uploads files to Google Gemini's [File API](https://ai.google.dev/gemini-api/docs/files).

Google uses a two-step resumable upload protocol internally, but this is
abstracted away — callers simply call `upload/3`.

## Usage

    {:ok, uploader} = LangChain.FileUploader.FileGoogle.new(%{api_key: "AI..."})

    {:ok, result} = LangChain.FileUploader.upload(uploader, file_bytes, %{
      filename: "document.pdf",
      mime_type: "application/pdf"
    })

    result.file_id
    #=> "files/abc-123"

    result.file_uri
    #=> "https://generativelanguage.googleapis.com/v1beta/files/abc-123"

Google identifies files by resource name (e.g. `"files/abc-123"`), which is
stored as `file_id` in the returned `FileResult`. The `file_uri` is also
available for use with `ContentPart.file_url!/2`.

Note: Files uploaded to Gemini expire after 48 hours.

# `t`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.4/lib/file_uploaders/file_google.ex#L52)

```elixir
@type t() :: %LangChain.FileUploader.FileGoogle{
  api_key: term(),
  endpoint: term(),
  receive_timeout: term(),
  req_opts: term()
}
```

# `delete`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.4/lib/file_uploaders/file_google.ex#L131)

Delete a file by its resource name.

`file_name` must be the Google resource name in the form `"files/{id}"`,
e.g. `"files/abc-123"`. This is the `file_id` value stored in `FileResult`.

# `get`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.4/lib/file_uploaders/file_google.ex#L99)

Retrieve file metadata by its resource name.

`file_name` must be the Google resource name in the form `"files/{id}"`,
e.g. `"files/abc-123"`. This is the `file_id` value stored in `FileResult`.

# `new`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.4/lib/file_uploaders/file_google.ex#L61)

```elixir
@spec new(attrs :: map()) :: {:ok, t()} | {:error, Ecto.Changeset.t()}
```

Setup a Google file uploader configuration.

# `new!`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.4/lib/file_uploaders/file_google.ex#L72)

```elixir
@spec new!(attrs :: map()) :: t() | no_return()
```

Setup a Google file uploader configuration and return it or raise an error if invalid.

# `request_upload_url`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.4/lib/file_uploaders/file_google.ex#L196)

```elixir
@spec request_upload_url(t(), String.t(), String.t(), non_neg_integer()) ::
  {:ok, String.t()} | {:error, LangChain.LangChainError.t()}
```

Request a presigned upload URL from Google's resumable upload endpoint (step 1 of 2).

Returns `{:ok, upload_url}` on success, or `{:error, LangChainError.t()}` on failure.
The returned URL can be passed to `upload_file_bytes/4` to complete the upload, or
forwarded directly to a client (e.g. a browser or mobile app) so it can upload
the file bytes itself without routing them through your server.

# `upload_file_bytes`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.4/lib/file_uploaders/file_google.ex#L244)

```elixir
@spec upload_file_bytes(t(), String.t(), binary(), non_neg_integer()) ::
  {:ok, LangChain.FileUploader.FileResult.t()}
  | {:error, LangChain.LangChainError.t()}
```

Upload raw file bytes to a presigned upload URL (step 2 of 2).

`upload_url` is obtained from `request_upload_url/4`. Returns `{:ok, FileResult.t()}` on
success, or `{:error, LangChainError.t()}` on failure.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
