diff --git a/app/controllers/active_storage/disk_controller_decorator.rb b/app/controllers/active_storage/disk_controller_decorator.rb index 8af75227..4c9c5166 100644 --- a/app/controllers/active_storage/disk_controller_decorator.rb +++ b/app/controllers/active_storage/disk_controller_decorator.rb @@ -27,17 +27,11 @@ module ActiveStorage site = Site.find_by_name token[:service_name] if remote_file?(token) - begin - url = request.body.read - body = Down.download(url, max_size: 111.megabytes) - checksum = Digest::MD5.file(body.path).base64digest - blob.metadata[:url] = url - blob.update_columns checksum: checksum, byte_size: body.size, metadata: blob.metadata - rescue StandardError => e - ExceptionNotifier.notify_exception(e, data: { key: token[:key], url: url, site: site.name }) - - head :payload_too_large - end + url = request.body.read + body = Down.download(url, max_size: 111.megabytes) + checksum = Digest::MD5.file(body.path).base64digest + blob.metadata[:url] = url + blob.update_columns checksum: checksum, byte_size: body.size, metadata: blob.metadata else body = request.body checksum = token[:checksum] @@ -54,6 +48,10 @@ module ActiveStorage end rescue ActiveStorage::IntegrityError head :unprocessable_entity + rescue Down::Error => e + ExceptionNotifier.notify_exception(e, data: { key: token[:key], url: url, site: site.name }) + + head :payload_too_large end private