# `Dagger.File`
[🔗](https://github.com/dagger/dagger/blob/v0.20.5/sdk/elixir/lib/dagger/gen/file.ex#L2)

A file.

# `t`

```elixir
@type t() :: %Dagger.File{client: term(), query_builder: term()}
```

# `as_env_file`

```elixir
@spec as_env_file(t(), [{:expand, boolean() | nil}]) :: Dagger.EnvFile.t()
```

Parse as an env file

# `as_json`

```elixir
@spec as_json(t()) :: Dagger.JSONValue.t()
```

Parse the file contents as JSON.

# `chown`

```elixir
@spec chown(t(), String.t()) :: t()
```

Change the owner of the file recursively.

# `contents`

```elixir
@spec contents(t(), offset_lines: integer() | nil, limit_lines: integer() | nil) ::
  {:ok, String.t()} | {:error, term()}
```

Retrieves the contents of the file.

# `digest`

```elixir
@spec digest(t(), [{:exclude_metadata, boolean() | nil}]) ::
  {:ok, String.t()} | {:error, term()}
```

Return the file's digest. The format of the digest is not guaranteed to be stable between releases of Dagger. It is guaranteed to be stable between invocations of the same Dagger engine.

# `export`

```elixir
@spec export(t(), String.t(), [{:allow_parent_dir_path, boolean() | nil}]) ::
  {:ok, String.t()} | {:error, term()}
```

Writes the file to a file path on the host.

# `id`

```elixir
@spec id(t()) :: {:ok, Dagger.FileID.t()} | {:error, term()}
```

A unique identifier for this File.

# `name`

```elixir
@spec name(t()) :: {:ok, String.t()} | {:error, term()}
```

Retrieves the name of the file.

# `search`

```elixir
@spec search(t(), String.t(),
  literal: boolean() | nil,
  multiline: boolean() | nil,
  dotall: boolean() | nil,
  insensitive: boolean() | nil,
  skip_ignored: boolean() | nil,
  skip_hidden: boolean() | nil,
  files_only: boolean() | nil,
  limit: integer() | nil,
  paths: [String.t()],
  globs: [String.t()]
) :: {:ok, [Dagger.SearchResult.t()]} | {:error, term()}
```

Searches for content matching the given regular expression or literal string.

Uses Rust regex syntax; escape literal ., [, ], {, }, | with backslashes.

# `size`

```elixir
@spec size(t()) :: {:ok, integer()} | {:error, term()}
```

Retrieves the size of the file, in bytes.

# `sync`

```elixir
@spec sync(t()) :: {:ok, t()} | {:error, term()}
```

Force evaluation in the engine.

# `with_name`

```elixir
@spec with_name(t(), String.t()) :: t()
```

Retrieves this file with its name set to the given name.

# `with_replaced`

```elixir
@spec with_replaced(t(), String.t(), String.t(),
  all: boolean() | nil,
  first_from: integer() | nil
) ::
  t()
```

Retrieves the file with content replaced with the given text.

If 'all' is true, all occurrences of the pattern will be replaced.

If 'firstAfter' is specified, only the first match starting at the specified line will be replaced.

If neither are specified, and there are multiple matches for the pattern, this will error.

If there are no matches for the pattern, this will error.

# `with_timestamps`

```elixir
@spec with_timestamps(t(), integer()) :: t()
```

Retrieves this file with its created/modified timestamps set to the given time.

---

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