Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails Image String to Image File

I currently save image strings (this is how they are provided through API) as a binary in my database but I need to (after creation), change this to a file structure, probably using Paperclip/Carrierwave and S3.

What is the best way to convert binary to image file e.g. jpg?

like image 545
amaseuk Avatar asked Nov 23 '25 13:11

amaseuk


1 Answers

This did the trick:

sio = StringIO.new(Base64.decode64(string))

[ source: base64 photo and paperclip -Rails ]

like image 172
amaseuk Avatar answered Nov 25 '25 03:11

amaseuk