JayData.org

Blobs

Author: Gábor Dolla May 22nd, 2013


JayData has been supporting blobs for some time but so far binary data was converted to base64 strings. From 1.3 we improved blob handling and now blob is a binary stream. The new internal converter subsystem allows easy conversion from many types to blob and vice versa, so you can convert from the following types to $data.Blob with a simple assignment:

  • String
  • Array
  • Number
  • Boolean
  • Blob
  • Uint8Array
  • Buffer
  • Object

$data.Blob has many functions so that you can do explicit conversion:

  • toString()
  • toBase64()
  • toArray()
  • toHexString()
  • toDataURL()

Let’s create a simple code which downloads images from the net and stores them in local storage:

Now let’s retrieve the images from local store and put them onto the screen: