refile / refile

Ruby file uploads, take 3
MIT License
2.45k stars 292 forks source link

Uploading Base64 images #458

Open txssseal opened 8 years ago

txssseal commented 8 years ago

I know in paperclip it is built in as of 4.0 that Base64 encoded images will upload without any extra work. Does refile have any built in support for uploading Base64 images?

jnicklas commented 8 years ago

A couple of questions:

  1. for what purpose? Base64 is a very inefficient encoding for large binary files. Its only advantage is being able to represent it somewhat sensibly in a non-binary file (like embedding in CSS).
  2. How would Refile distinguish a Base64 encoded string?
kdiogenes commented 8 years ago

Some crop libs uses base64 to represent the cropped image: http://foliotek.github.io/Croppie/

SimonBrazell commented 6 years ago

Where:

class Test < ApplicationRecord
  attachment :image
end

In your controller you can do this to attach Base64: @test.image = StringIO.new(Base64.decode64(params[:image]))