### Phoenix Controller File Upload and Scan Source: https://github.com/ramortegui/clamxir/blob/master/README.md Integrate Clamxir into a Phoenix controller action to scan uploaded files for viruses before processing them. This example assumes clamavdscann is installed. ```elixir def upload(conn, params) do file = params["index"]["file"] # Requires to have clamavdscann to work case Clamxir.safe?(%Clamxir{daemonize: true}, file.path) do true -> # Process the file and ... conn |> put_flash(:info, "Created successfully") |> redirect(to: "/") false -> conn |> put_flash(:error, "Virus!!") |> redirect(to: "/") end end ``` -------------------------------- ### Scan File with Default Configuration Source: https://github.com/ramortegui/clamxir/blob/master/README.md Use the Clamxir.safe? function to scan a file using the default configuration. ```elixir iex> Clamxir.safe?(%Clamxir{}, "/path/file") ``` -------------------------------- ### Scan File with Stream Enabled Source: https://github.com/ramortegui/clamxir/blob/master/README.md Enable the stream option to pass the --stream flag to clamdscan, which can help avoid permission issues. ```elixir iex> Clamxir.safe?(%Clamxir{stream: true}, "/path/file") ``` -------------------------------- ### Default Clamxir Configuration Source: https://github.com/ramortegui/clamxir/blob/master/README.md The default configuration for Clamxir is represented by the %Clamxir{} struct. Key options include daemonize, stream, and check. ```elixir %Clamxir{ daemonize: false, stream: false, check: fase } ``` -------------------------------- ### Scan File with Check Enabled Source: https://github.com/ramortegui/clamxir/blob/master/README.md Enable the check option to validate scanner availability before attempting to run it. ```elixir iex> Clamxir.safe?(%Clamxir{check: true}, "/path/file") ``` -------------------------------- ### Add Clamxir to Mix Dependencies Source: https://github.com/ramortegui/clamxir/blob/master/README.md Add the clamxir package to your project's dependencies in the mix.exs file. ```elixir def deps do [ {:clamxir, "~> 0.1.8"} ] end ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.