Fails on PNGs (or other base64 strings that aren't packed)
baoist opened this issue · 3 comments
Looks like this happens around: https://github.com/lebedev-yury/carrierwave-base64/blob/master/lib/carrierwave/base64/orm/activerecord.rb#L10
data.strip.end_with?("==")
Can you please give me an example of data, which you try to submit?
I also experienced this problem and solved it by removing that condition. It turns out not all image's base64 strings end with "==". You can read more about that here:
http://stackoverflow.com/questions/6916805/why-does-a-base64-encoded-string-have-an-sign-at-the-end
Regarding my solution I'm not really sure if it's the best one but it works anyways. On the other hand we can add a regular expression to make sure the string is a base64 encoded one but it might not be very efficient since most of the base64 strings are gonna be really long.
If so, then it makes to sense to keep an additional condition in the code. The check for the string type should already do the separation of uploaded files from encoded strings.
Can you do a pull request then?