I have a base64 encoded string of an image file. I need to save it using Paper Clip
My controller code
@driver = User.find(6) encoded_file = Base64.encode64(File.open('/pjt_path/public/test.jpg').read) decoded_file = Base64.decode64(encoded_file) @driver.profile_pic = StringIO.open(decoded_file) @driver.save
In my user model
has_attached_file :profile_pic, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => '/icon.jpg'
Currently, the file is saved as a text file (stringio.txt). But when I change the extension to JPG, I can view it as an image. How to correctly display an image using StringIO.
I have rails 3.2, ruby 1.9.2, paperclip 3.0.3
ruby ruby-on-rails file-upload stringio paperclip
Amal kumar s
source share