Module: UPS::Utils

Defined in:
lib/ups/utils.rb

Class Method Summary collapse

Class Method Details

.base64_to_file(contents, extension) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/ups/utils.rb', line 3

def self.base64_to_file(contents, extension)
  file_config = ['ups', extension]
  Tempfile.new(file_config, nil, encoding: 'ascii-8bit').tap do |file|
    begin
      file.write Base64.decode64(contents)
    ensure
      file.rewind
    end
  end
end