soyjeansoy

soyjeansoy

Plug.Parsers.RequestTooLargeError when uploading large files

Hi, how can i upload large file? it throws Plug.Parsers.RequestTooLargeError even though i added length in Plug.Parsers.

# endpoint.ex
  plug Plug.Parsers,
    parsers: [
      :urlencoded,
      {:multipart, length: 100_000_000},
      :json
    ],
    length: 100_000_000,
    pass: ["*/*"],
    json_decoder: Phoenix.json_library()

My heex template form has multipart and file_input/3 has multiple attribute. I’m uploading 3 files, no larger than 5mb each and it throws this:

Plug.Parsers.RequestTooLargeError at POST /upload
the request is too large. If you are willing to process larger requests, please give a :length to Plug.Parsers
lib/plug/parsers.ex
350
351      {:next, conn} ->
352        reduce(conn, rest, type, subtype, params, pass, query_string_length, validate_utf8)
353
354      {:error, :too_large, _conn} ->
355        raise RequestTooLargeError
356    end
357  end
358
359  defp reduce(conn, [], type, subtype, _params, pass, query_string_length, validate_utf8) do
360    if accepted_mime?(type, subtype, pass) do

Tried also uploading a single file that’s 20mb and still throws the same error. What did i miss?

Most Liked

LostKobrakai

LostKobrakai

For something smallish it does make sense to update the limits, but for larger uploads (imo start at ~30-50 MB) I’d suggest using streamed (e.g. LV uploads) or chunked uploads (e.g. tus protocol).

LostKobrakai

LostKobrakai

Even with a dedicated storage system there’s benefit in chunked uploads though – especially around the ability to reupload on failures.

kokolegorille

kokolegorille

Yes, but waffle is not the reason…

Last Post!

apoorv-2204

apoorv-2204

what about the info if we want to give to user , like flash , saying this is the upload limit.

Where Next?

Popular in Questions Top

jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
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

Other popular topics Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
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
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
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

We're in Beta

About us Mission Statement