MatijaL

MatijaL

Strange behaviour when using LiveView Uploads on Fly.io - {:error, :enoent} but not every time

Hi,

I have a small LiveView app deployed on Fly.io and sometimes, when uploading an image, I encounter strange behavior. I click browse, I select image and image preview shows, I click submit and image is uploaded, this is how it should work and works most of the time, but sometimes, something happens and uploading breaks.

In fly logs, I get {:error, :enoent} error. I used dbg to see if the file exists, and it does. So, the file exists and when it should be copied from /tmp/ folder to /uploads folder, it breaks for some reason.

As I already mentioned, this is happening only sometimes, most of the time it works fine and that makes it quite hard to debug. This doesn’t happen on my dev machine. Do you have any idea what could be causing this kind of behavior?

FILE EXISTS: /tmp/plug-1711-iIkC/live_view_upload-1711634767-822835485870-1
COPY ERROR: enoent
[lib/myapp/helpers/file_manager.ex:60: MyApp.Helpers.FileManager.copy_file/2]
path #=> "/tmp/plug-1711-iIkC/live_view_upload-1711634767-822835485870-1"
[lib/myapp/helpers/file_manager.ex:61: MyApp.Helpers.FileManager.copy_file/2]
dest #=> "/uploads/tmp/live_view_upload-1711634767-822835485870-1.jpg"
warning: consuming uploads requires a return signature matching:
    {:ok, value} | {:postpone, value}
got:
    {:error, :enoent}
defp copy_file(path, dest) do
    case File.cp(path, dest) do
      :ok ->
        {:ok, nil}
      {:error, reason} ->
        {:error, reason}
    end
  end

First Post!

kokolegorille

kokolegorille

Maybe it has to do with the tmp file being deleted after the process ends?

Did this happen for big image files?

Do You try to save in async mode?

Where Next?

Popular in Questions Top

chokchit
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2733ms. You can configure how long re...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
JulienCorb
I am trying to implement my new.html.eex file to create new posts on my website. new.html.eex: <h1>Create Post</h1> <%= ...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement