Topic: Base64 upload


I am working on a project where a mobile phone sends a base64 encoded picture to the rails application and it needs to be saved.
I tried various example over the internet but none worked.
With some the file managed to be saved, but it was corrupted (it wasn't the picture).

I tried with Tempfile, with, (with "rb") and f.write and none saved the real image.
Also I tried different encoded images, different extensions, added image type where it was required, but nothing seems to work.

I am using paperclip for uploading throw forms.

Can someone give me a reference or something ?
Thank you.

Last edited by shumi (2013-06-04 16:11:31)

Re: Base64 upload

Found the issue.

The issue was that the spaces in the base64 encoded image were not +

So I fixed this with replacing the spaces with pluses(+)

decoded_image.gsub!(' ', '+')

Last edited by shumi (2013-06-05 14:13:52)