Class: CarrierWave::Base64ImageContent::Base64StringIO
- Inherits:
-
StringIO
- Object
- StringIO
- CarrierWave::Base64ImageContent::Base64StringIO
- Defined in:
- lib/carrierwave/base64_image_content/base64_string_io.rb
Defined Under Namespace
Classes: ArgumentError
Instance Attribute Summary collapse
-
#file_format ⇒ Object
Returns the value of attribute file_format.
-
#file_name ⇒ Object
Returns the value of attribute file_name.
Instance Method Summary collapse
-
#initialize(encoded_file) ⇒ Base64StringIO
constructor
A new instance of Base64StringIO.
- #original_filename ⇒ Object
Constructor Details
#initialize(encoded_file) ⇒ Base64StringIO
Returns a new instance of Base64StringIO.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/carrierwave/base64_image_content/base64_string_io.rb', line 14 def initialize(encoded_file) description, encoded_bytes = encoded_file.split(',') raise ArgumentError unless encoded_bytes raise ArgumentError if encoded_bytes == '(null)' @file_name = Digest::SHA256.hexdigest(encoded_file) @file_format = get_file_format(description) bytes = Base64.strict_decode64(encoded_bytes) super(bytes) end |
Instance Attribute Details
#file_format ⇒ Object
Returns the value of attribute file_format.
10 11 12 |
# File 'lib/carrierwave/base64_image_content/base64_string_io.rb', line 10 def file_format @file_format end |
#file_name ⇒ Object
Returns the value of attribute file_name.
10 11 12 |
# File 'lib/carrierwave/base64_image_content/base64_string_io.rb', line 10 def file_name @file_name end |
Instance Method Details
#original_filename ⇒ Object
27 28 29 |
# File 'lib/carrierwave/base64_image_content/base64_string_io.rb', line 27 def original_filename File.basename("#{@file_name}.#{@file_format}") end |