If your images are not too large, placing them in a database with a binary RoR type makes a lot of sense. If you have database replicas, images can be copied for free to other sites, there are no problems regarding lost or widowed images, and problems with atomic transactions become much easier.
On the other hand, Nessence is right that Base64, like any level of encoding, adds load on the network, memory and processor load on transactions. If network bandwidth is your main concern, make sure your web service accepts and offers deflate / gzip compressed connections. This will reduce the cost of Base64 data at the network level, although it will cost even more memory and CPU utilization.
These are architectural issues that need to be discussed with your team and / or client.
Finally, let me tell you about RoR XML REST support. The Rails :binary database type will become <object type="binary" encoding="base64">...</object> XML objects when rendering in XML using code like this, by default:
def show @myobject = MyObject.find(:id) respond_to do |format| format.xml { render => @myobject } end end
This works great for GET operations, and PUT and POST operations are just as easy to write. A trap is a Rails PUT or POST operation that does not accept the same tags. This is because from_xml does not interpret the type="binary" tag, but instead searches for type="binaryBase64" . There is a patch bug on the Rails Beacon website to fix this.
source share