diff --git a/app/jobs/team_zip_export_job.rb b/app/jobs/team_zip_export_job.rb index b2367294d..de060b852 100644 --- a/app/jobs/team_zip_export_job.rb +++ b/app/jobs/team_zip_export_job.rb @@ -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 - file_name = preview.image.filename.to_s - file_data = preview.image.download + 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")) diff --git a/app/models/asset.rb b/app/models/asset.rb index 64a9e1235..4e85c9093 100644 --- a/app/models/asset.rb +++ b/app/models/asset.rb @@ -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