Nomad changes
All checks were successful
Deploy fil (kreuzberg) / deploy (push) Successful in 49s

This commit is contained in:
Henrik Jess Nielsen
2026-06-01 23:40:55 +02:00
parent 72b1a0a6ed
commit b4c07d3693
5723 changed files with 1130655 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
```elixir title="Elixir"
defmodule Example do
def robust_extract(path) do
with {:file_exists, true} <- {:file_exists, File.exists?(path)},
{:read, {:ok, content}} <- {:read, File.read(path)},
{:mime, {:ok, mime_type}} <- {:mime, detect_mime_type(content)},
{:extract, {:ok, result}} <- {:extract, Kreuzberg.extract_bytes_sync(content, mime_type, nil)} do
{:ok, result}
else
{:file_exists, false} ->
{:error, "File not found: #{path}"}
{:read, {:error, reason}} ->
{:error, "Failed to read file: #{inspect(reason)}"}
{:mime, {:error, reason}} ->
{:error, "MIME detection failed: #{reason}"}
{:extract, {:error, reason}} ->
{:error, "Extraction failed: #{reason}"}
end
end
defp detect_mime_type(content) do
Kreuzberg.detect_mime_type_from_bytes(content)
end
end
```