mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-28 11:14:24 +08:00
Fix file previews in project exports [SCI-9619] (#6548)
This commit is contained in:
parent
e73543dd90
commit
d3ba70c2bf
2 changed files with 12 additions and 4 deletions
|
@ -187,11 +187,19 @@ class TeamZipExportJob < ZipExportJob
|
||||||
def prepare_preview(asset)
|
def prepare_preview(asset)
|
||||||
if asset.previewable? && !asset.list?
|
if asset.previewable? && !asset.list?
|
||||||
preview = asset.inline? ? asset.large_preview : asset.medium_preview
|
preview = asset.inline? ? asset.large_preview : asset.medium_preview
|
||||||
return unless preview.image.attached?
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
if preview.is_a?(ActiveStorage::Preview)
|
||||||
|
return unless preview.image.attached?
|
||||||
|
|
||||||
file_name = preview.image.filename.to_s
|
file_name = preview.image.filename.to_s
|
||||||
file_data = preview.image.download
|
file_data = preview.image.download
|
||||||
|
else
|
||||||
|
return unless preview.processed?
|
||||||
|
|
||||||
|
file_name = preview.filename.to_s
|
||||||
|
file_data = preview.download
|
||||||
|
end
|
||||||
rescue ActiveStorage::FileNotFoundError => e
|
rescue ActiveStorage::FileNotFoundError => e
|
||||||
Rails.logger.error(e.message)
|
Rails.logger.error(e.message)
|
||||||
Rails.logger.error(e.backtrace.join("\n"))
|
Rails.logger.error(e.backtrace.join("\n"))
|
||||||
|
|
|
@ -473,7 +473,7 @@ class Asset < ApplicationRecord
|
||||||
|
|
||||||
def previewable_image?
|
def previewable_image?
|
||||||
preview_image.attached? ||
|
preview_image.attached? ||
|
||||||
file.blob&.content_type =~ %r{^image/#{Regexp.union(Constants::WHITELISTED_IMAGE_TYPES)}}
|
file.blob&.content_type&.match?(%r{^image/#{Regexp.union(Constants::WHITELISTED_IMAGE_TYPES)}})
|
||||||
end
|
end
|
||||||
|
|
||||||
def step_or_result_or_repository_asset_value
|
def step_or_result_or_repository_asset_value
|
||||||
|
|
Loading…
Reference in a new issue