encode and decode image in Base64 in rails
require "base64"
encoded_string = Base64.encode64(open("https://s3.amazonaws.com/cdn.
yourwellnessroom.com/i/pillarimages/eat/E22.jpg") { |io| io.read })
decode_img= Base64.decode64(encoded_string)
File.open('image.png', 'wb') { |f| f.write(decode_img) }
user.image = image.png'
user.save
encoded_string = Base64.encode64(open("https://s3.amazonaws.com/cdn.
yourwellnessroom.com/i/pillarimages/eat/E22.jpg") { |io| io.read })
decode_img= Base64.decode64(encoded_string)
File.open('image.png', 'wb') { |f| f.write(decode_img) }
user.image = image.png'
user.save
Comments
Post a Comment