Storing image as base64string (varchar(max)) or varbinary
What are the pro's and con's of each?
My requirements are:
- I want to be able to encrypt the image
- Easily accessible on a mobile device through a webserver (RESTful API)
- Easily accessible on a mobile device through a local database like SQLLite
The databases im using on the server side is MS SQL 2005. I bel开发者_Python百科eive SQLLite and MS SQL 2005 can support both varchar and varbinary (BLOB on sqllite)
Base64 only uses 6 out of 8 bits in a byte. It dates back to the time when emails were transmitted over lines that were not 7 bits safe.
Back then, you'd store the image as a binary blob, because that required 33% less storage space. Then you'd convert it on the fly when a client requests a base64
encoded string. Conversion to base64 is very cheap.
That still makes sense today-- store it as a binary
, transmit it like whatever the client requests.
精彩评论