mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-11 01:44:34 +08:00
13 lines
419 B
Ruby
13 lines
419 B
Ruby
# frozen_string_literal: true
|
|
|
|
module ActiveStorageConcerns
|
|
extend ActiveSupport::Concern
|
|
|
|
def convert_variant_to_base64(variant)
|
|
encoded_data = Base64.strict_encode64(variant.service.download(variant.processed.key))
|
|
"data:#{variant.image.blob.content_type};base64,#{encoded_data}"
|
|
rescue StandardError => e
|
|
Rails.logger.error e.message
|
|
"data:#{variant.image.blob.content_type};base64,"
|
|
end
|
|
end
|