Data URI vs binary in database

I send the image to the server using the UATA URI (client side using canvas). I now have two options: I can save the "image" as a string in the varchar (max) column, or I can convert it to byte [] and save it as varbinary (max).

As for the implementation, the efforts are the same. I am trying to determine what would be more efficient if 1: space in the database and 2: image display. Has anyone seen any analysis on this or has a good way to measure it?

AN FYI - 3 KB image is about 100 thousand characters in the database.

Usage: ASP.NET 4.5, MVC, SQL Server 2008

To clarify

I can either save the image to the database using the byte [] in the varbinary (MAX) column, as it usually happens, or I can save the UATA UATA from an HTML5 canvas that looks like data: image / png; base64, iVBORw0K ... in the varchar (max) column.

Storing byte [] is typical and needs no further explanation. Storing a UATA URI is just a string, and displaying the image will matter:

<img src="data:image/png;base64,iVBORw0K" /> or
<img src="@Model.Uri" />

My question is which one is more efficient and space-saving, and if there is any documentation, white paper or analysis around this specific comparison.

+5
source share
1 answer

, Binging Google, , 20K (, ) . PetaPoco . - - , . , , DATA URI .

URI . , . - .

. : ImageResult ( ActionResult, ) MVC ( http) URI SRC ( src= "@Model.Uri" ). , . Chrome dev:

ImageResult: 2 requests, 200ms, 3.2KB
DATA URI: 2 requests, 200ms, 3.9KB

, ImageResult (byte []) , . URI URI .

[] - , .

: i7, 8GB Ram, SSD, SQL Server 2012, IIS Express

-, . , , HTTP, etag, ..

+3

All Articles