scinote-web/app/models/concerns/image_variant_processing.rb
aignatov-bio a3b2c7d5fe
Fix report image issues [SCI-3772] (#1983)
* Fix report image issues

* Small fixes
2019-09-12 09:02:45 +02:00

15 lines
517 B
Ruby

# frozen_string_literal: true
module ImageVariantProcessing
extend ActiveSupport::Concern
def convert_variant_to_base64(variant)
image_link = if ENV['ACTIVESTORAGE_SERVICE'] == 'amazon'
URI.parse(variant.processed.service_url).open.to_a.join
else
File.open(variant.processed.service_url).to_a.join
end
encoded_data = Base64.strict_encode64(image_link)
"data:#{variant.image.blob.content_type};base64,#{encoded_data}"
end
end