mirror of
https://0xacab.org/sutty/sutty
synced 2025-03-14 17:08:21 +00:00
Merge branch 'issue-17889' into production.panel.sutty.nl
This commit is contained in:
commit
617e4ced1f
1 changed files with 20 additions and 10 deletions
|
@ -11,7 +11,7 @@ module ActiveStorage
|
||||||
# Permitir incrustar archivos subidos (especialmente PDFs) desde
|
# Permitir incrustar archivos subidos (especialmente PDFs) desde
|
||||||
# otros sitios.
|
# otros sitios.
|
||||||
def show
|
def show
|
||||||
original_show.tap do |s|
|
original_show.tap do |_s|
|
||||||
response.headers.delete 'X-Frame-Options'
|
response.headers.delete 'X-Frame-Options'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -24,20 +24,28 @@ module ActiveStorage
|
||||||
if (token = decode_verified_token)
|
if (token = decode_verified_token)
|
||||||
if acceptable_content?(token)
|
if acceptable_content?(token)
|
||||||
blob = ActiveStorage::Blob.find_by_key! token[:key]
|
blob = ActiveStorage::Blob.find_by_key! token[:key]
|
||||||
site = Site.find_by_name token[:service_name]
|
site = Site.find_by_name! token[:service_name]
|
||||||
|
|
||||||
if remote_file?(token)
|
if remote_file?(token)
|
||||||
url = request.body.read
|
begin
|
||||||
body = Down.download(url, max_size: 111.megabytes)
|
url = request.body.read
|
||||||
checksum = Digest::MD5.file(body.path).base64digest
|
body = Down.download(url, max_size: 111.megabytes)
|
||||||
blob.metadata[:url] = url
|
checksum = Digest::MD5.file(body.path).base64digest
|
||||||
blob.update_columns checksum: checksum, byte_size: body.size, metadata: blob.metadata
|
blob.metadata[:url] = url
|
||||||
|
blob.update_columns checksum:, byte_size: body.size, metadata: blob.metadata
|
||||||
|
rescue StandardError => e
|
||||||
|
ExceptionNotifier.notify_exception(e, data: { key: token[:key], url:, site: site.name })
|
||||||
|
|
||||||
|
head :content_too_large
|
||||||
|
|
||||||
|
return
|
||||||
|
end
|
||||||
else
|
else
|
||||||
body = request.body
|
body = request.body
|
||||||
checksum = token[:checksum]
|
checksum = token[:checksum]
|
||||||
end
|
end
|
||||||
|
|
||||||
named_disk_service(token[:service_name]).upload token[:key], body, checksum: checksum
|
named_disk_service(site.name).upload(token[:key], body, checksum:)
|
||||||
|
|
||||||
site.static_files.attach(blob)
|
site.static_files.attach(blob)
|
||||||
else
|
else
|
||||||
|
@ -46,7 +54,9 @@ module ActiveStorage
|
||||||
else
|
else
|
||||||
head :not_found
|
head :not_found
|
||||||
end
|
end
|
||||||
rescue ActiveStorage::IntegrityError
|
rescue ActiveRecord::ActiveRecordError, ActiveStorage::Error => e
|
||||||
|
ExceptionNotifier.notify_exception(e, data: { token: })
|
||||||
|
|
||||||
head :unprocessable_entity
|
head :unprocessable_entity
|
||||||
rescue Down::Error => e
|
rescue Down::Error => e
|
||||||
ExceptionNotifier.notify_exception(e, data: { key: token[:key], url: url, site: site.name })
|
ExceptionNotifier.notify_exception(e, data: { key: token[:key], url: url, site: site.name })
|
||||||
|
@ -62,7 +72,7 @@ module ActiveStorage
|
||||||
|
|
||||||
def page_not_found(exception)
|
def page_not_found(exception)
|
||||||
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
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue