SHARE
TWEET

Untitled

a guest Jan 26th, 2013 21 Never
  1. data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/...
  2.        
  3. File.open("#{Rails.root}/public/images/#{self.id}.jpg", "w+") do |f|
  4.   f.write(data)
  5. end
  6.        
  7. File.open("#{Rails.root}/public/images/#{self.id}.jpg", "w+") do |f|
  8.   decoded_data = Base64.decode64(data)
  9.   image_data = StringIO.new(decoded_data)
  10.   f.write(image_data)
  11. end
  12.        
  13. f.write Base64.decode64(data).force_encoding('UTF-8')
RAW Paste Data
Top