开发者

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

开发者 https://www.devze.com 2023-03-14 06:34 出处:网络
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)

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

精彩评论

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