Hi guys,
I deployed a small LiveView app on Fly.io but when I try to upload an image and run System.cmd() on it, it returns :enoent which should indicate that the file doesn’t exists, but it does, the function checks if ti exists and I also checked manually using Fly.io iex console.
def content_type(filepath) do
with true <- File.exists?(filepath),
{file_utility_output, 0} <- System.cmd("file", ["--mime", "--brief", filepath])
do
content_type =
Regex.named_captures(
~r/^(?<content_type>.+);/,
file_utility_output
)["content_type"]
{:ok, content_type}
else
{error, 1} ->
{:error, error}
false ->
"inode/x-empty"
end
end
Path example
/uploads/tmp/live_view_upload-1710842554-413969956620-1.png
Trying to run it manually from Fly.io iex
filepath = "/uploads/tmp/live_view_upload-1710842554-413969956620-1.png"
iex(...)6> File.exists?(filepath)
true
iex(...)7> dbg System.cmd("file", ["--mime", "--brief", filepath])
** (ErlangError) Erlang error: :enoent
(elixir 1.16.0) lib/system.ex:1101: System.cmd("file", ["--mime", "--brief", filepath], [])
iex:7: (file)
Do you have any idea what could cause this behaviour?