mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-27 18:52:07 +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)
|
||||
if asset.previewable? && !asset.list?
|
||||
preview = asset.inline? ? asset.large_preview : asset.medium_preview
|
||||
return unless preview.image.attached?
|
||||
|
||||
begin
|
||||
if preview.is_a?(ActiveStorage::Preview)
|
||||
return unless preview.image.attached?
|
||||
|
||||
file_name = preview.image.filename.to_s
|
||||
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
|
||||
Rails.logger.error(e.message)
|
||||
Rails.logger.error(e.backtrace.join("\n"))
|
||||
|
|
|
@ -473,7 +473,7 @@ class Asset < ApplicationRecord
|
|||
|
||||
def previewable_image?
|
||||
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
|
||||
|
||||
def step_or_result_or_repository_asset_value
|
||||
|
|
Loading…
Reference in a new issue