diff --git a/app/controllers/active_storage/disk_controller_decorator.rb b/app/controllers/active_storage/disk_controller_decorator.rb index ec3ac0b4..07a166c3 100644 --- a/app/controllers/active_storage/disk_controller_decorator.rb +++ b/app/controllers/active_storage/disk_controller_decorator.rb @@ -29,7 +29,7 @@ module ActiveStorage if remote_file?(token) begin url = request.body.read - body = Down.download(url, max_size: 111.megabytes) + body = Down.download(url, max_size: max_download_size) checksum = Digest::MD5.file(body.path).base64digest blob.metadata[:url] = url blob.update_columns checksum: checksum, byte_size: body.size, metadata: blob.metadata @@ -56,6 +56,11 @@ module ActiveStorage head :unprocessable_entity end + def limits(max_upload_size, max_download_size) + ruby_hash = { "max_upload_size": max_upload_size, "max_download_size": max_download_size } + json_string = JSON.generate(ruby_hash) + end + private def remote_file?(token) @@ -66,6 +71,14 @@ module ActiveStorage head :not_found ExceptionNotifier.notify_exception(exception, data: {params: params.to_hash}) end + + def max_upload_size + max_upload_size_mbs = ENV['MAX_UPLOAD_SIZE'].to_i.megabytes + end + + def max_download_size + max_download_size_mbs = ENV['MAX_DOWNLOAD_SIZE'].to_i.megabytes + end end end end