Sha256: 91bcb1a07b05d2201d1bb433bf3dea3a90e02aeafd7c155a57931ebd5249a28f
Contents?: true
Size: 679 Bytes
Versions: 2
Compression:
Stored size: 679 Bytes
Contents
module Carrierwave module Base64 class Base64StringIO < StringIO class ArgumentError < StandardError; end attr_accessor :file_format def initialize(encoded_file) description, encoded_bytes = encoded_file.split(",") raise ArgumentError unless encoded_bytes @file_format = get_file_format description bytes = ::Base64.decode64 encoded_bytes super bytes end def original_filename File.basename("file.#{@file_format}") end private def get_file_format(description) regex = /([a-z]+);base64\z/ regex.match(description).try(:[], 1) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
carrierwave-base64-1.5 | lib/carrierwave/base64/base64_string_io.rb |
carrierwave-base64-1.4 | lib/carrierwave/base64/base64_string_io.rb |