From 9c4695b39670870e92318443e8b3883ff7045c02 Mon Sep 17 00:00:00 2001 From: Bodo Tasche Date: Fri, 17 May 2024 23:18:15 +0200 Subject: [PATCH] Added max_body_length to hackney options --- lib/waffle/file.ex | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/waffle/file.ex b/lib/waffle/file.ex index c630628..6b70a5f 100644 --- a/lib/waffle/file.ex +++ b/lib/waffle/file.ex @@ -173,6 +173,7 @@ defmodule Waffle.File do # hackney :connect_timeout - timeout used when establishing a connection, in milliseconds # hackney :recv_timeout - timeout used when receiving from a connection, in milliseconds + # hackney :max_body_length - maximum size of the file to download, in bytes. Defaults to :infinity # :backoff_max - maximum backoff time, in milliseconds # :backoff_factor - a backoff factor to apply between attempts, in milliseconds defp get_remote_path(remote_path, definition) do @@ -214,7 +215,9 @@ defmodule Waffle.File do end defp body(client_ref, response_headers) do - case :hackney.body(client_ref) do + max_body_length = Application.get_env(:waffle, :max_body_length, :infinity) + + case :hackney.body(client_ref, max_body_length) do {:ok, body} -> response_headers = :hackney_headers.new(response_headers) filename = content_disposition(response_headers)