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:



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/locomotive/carrierwave/patches.rb', line 43

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.



41
42
43
# File 'lib/locomotive/carrierwave/patches.rb', line 41

def file_format
  @file_format
end

#original_filenameObject

Returns the value of attribute original_filename.



41
42
43
# File 'lib/locomotive/carrierwave/patches.rb', line 41

def original_filename
  @original_filename
end