mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-23 01:46:21 +00:00
feat: métodos en disk_controller_decorator #102
This commit is contained in:
parent
57377279a5
commit
628a5fedb2
1 changed files with 14 additions and 1 deletions
|
@ -29,7 +29,7 @@ module ActiveStorage
|
||||||
if remote_file?(token)
|
if remote_file?(token)
|
||||||
begin
|
begin
|
||||||
url = request.body.read
|
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
|
checksum = Digest::MD5.file(body.path).base64digest
|
||||||
blob.metadata[:url] = url
|
blob.metadata[:url] = url
|
||||||
blob.update_columns checksum: checksum, byte_size: body.size, metadata: blob.metadata
|
blob.update_columns checksum: checksum, byte_size: body.size, metadata: blob.metadata
|
||||||
|
@ -56,6 +56,11 @@ module ActiveStorage
|
||||||
head :unprocessable_entity
|
head :unprocessable_entity
|
||||||
end
|
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
|
private
|
||||||
|
|
||||||
def remote_file?(token)
|
def remote_file?(token)
|
||||||
|
@ -66,6 +71,14 @@ module ActiveStorage
|
||||||
head :not_found
|
head :not_found
|
||||||
ExceptionNotifier.notify_exception(exception, data: {params: params.to_hash})
|
ExceptionNotifier.notify_exception(exception, data: {params: params.to_hash})
|
||||||
end
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue