Class: CarrierWave::Uploader::Base64Download::Base64StringIO

Inherits:
StringIO
  • Object
show all
Defined in:
lib/locomotive/carrierwave/patches.rb

Overview

Based on Yury Lebedev’s work (github.com/lebedev-yury/carrierwave-base64) Our version relies on the remote_<name>_url field. Moreover, we support passing filename into the base64 string.

Defined Under Namespace

Classes: ArgumentError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(encoded_file) ⇒ Base64StringIO

Returns a new instance of Base64StringIO.

Raises:



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/locomotive/carrierwave/patches.rb', line 32

def initialize(encoded_file)
  description, encoded_bytes = encoded_file.split(',')

  raise ArgumentError unless encoded_bytes

  @file_format        = get_file_format(description)
  @original_filename  = get_original_filename(description)

  bytes = ::Base64.decode64 encoded_bytes

  super bytes
end

Instance Attribute Details

#file_formatObject

Returns the value of attribute file_format.



30
31
32
# File 'lib/locomotive/carrierwave/patches.rb', line 30

def file_format
  @file_format
end

#original_filenameObject

Returns the value of attribute original_filename.



30
31
32
# File 'lib/locomotive/carrierwave/patches.rb', line 30

def original_filename
  @original_filename
end