5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-26 09:06:21 +00:00

feat: métodos en disk_controller_decorator #102

This commit is contained in:
maki 2024-06-06 16:16:52 -03:00
parent 57377279a5
commit 628a5fedb2

View file

@ -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