开发者

Storing image as base64string (varchar(max)) or varbinary

What are the pro's and con's of each?

My requirements are:

  1. I want to be able to encrypt the image
  2. Easily accessible on a mobile device through a webserver (RESTful API)
  3. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜