I’ve got a file upload that uploads an image to a server. That image is
then manipulated via rmagick.
I’ve only just found that for files less than 10KB in size, that the
object is not a Tempfile, but a StringIO. If it’s a Tempfile (e.g.
image file is over 10KB) the site works fine, but for small images, it
fails!
Thing is, that I can’t figure out how to get a StringIO into RMagick to
create an imagemagick image, so that I can manipulate it.
What this mess does is hide my 'image' field. 'image' is always
SQL-safe Base64 encoded, while image_binary is the undecoded version.
I won't let people store more than the correct size in my database, so
I adjust it on input and just base64 decode it on output. There are
times where I want the actual base64 version (email springs to mind)
but usually I just refer to image_binary and send that.