module MediaMagic::Operations

Public Instance Methods

decode(encoded_string, file_name) click to toggle source

encoded_string should be the output of encode method file_name will be the file genrated out of encoded_string

# File lib/media-magic.rb, line 15
def decode(encoded_string, file_name)
  decoded_media = Base64.decode64(encoded_string)
  File.open(file_name, 'w+') { |f| f.write decoded_media }
end
encode(uri) click to toggle source

uri can be filename or a url or an image or any other media e.g ‘/path/to/file’

'http://url/to/media_file'
# File lib/media-magic.rb, line 9
def encode(uri)
  Base64.encode64(open(uri, 'rb') { |f| f.read })
end