title: File upload Base64 encoded string in PaperClip using Rails
body: <p>I have at base64 encoded string of a image file. I need to save it using Paper Clip</p>
  
  <p>My Controller code is  </p>
  
  <pre><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
  </code></pre>
  
  <p>In my user model</p>
  
  <pre><code> has_attached_file :profile_pic, :styles =&gt; { :medium =&gt; "300x300&gt;", :thumb =&gt; "100x100&gt;" }, :default_url =&gt; '/icon.jpg'
  </code></pre>
  
  <p>Currently the file is saved as a text file(stringio.txt). But when I change the extension to  JPG I can view it as image. How can I name the image correctly using StringIO.</p>
  
  <p>I am having rails 3.2, ruby 1.9.2, paperclip 3.0.3 </p>