How to use the pouchdb-binary-utils.blob function in pouchdb-binary-utils

To help you get started, we’ve selected a few pouchdb-binary-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pouchdb / pouchdb / packages / node_modules / pouchdb-adapter-leveldb-core / src / readAsBlobOrBuffer-browser.js View on Github external
function readAsBlobOrBuffer(storedObject, type) {
  // In the browser, we've stored a binary string. This now comes back as a
  // browserified Node-style Buffer (implemented as a typed array),
  // but we want a Blob instead.
  var byteArray = new Uint8Array(storedObject);
  return createBlob([byteArray], {type: type});
}
github stockulus / pouchdb-react-native / packages / pouchdb-adapter-leveldb-core-rn / src / readAsBlobOrBuffer-browser.js View on Github external
function readAsBlobOrBuffer(storedObject, type) {
  // In the browser, we've stored a binary string. This now comes back as a
  // browserified Node-style Buffer (implemented as a typed array),
  // but we want a Blob instead.
  var byteArray = new Uint8Array(storedObject);
  return createBlob([byteArray], {type: type});
}
github stockulus / pouchdb-react-native / packages / pouchdb-adapter-leveldb-core-rn / lib / index-browser.js View on Github external
function readAsBlobOrBuffer(storedObject, type) {
  // In the browser, we've stored a binary string. This now comes back as a
  // browserified Node-style Buffer (implemented as a typed array),
  // but we want a Blob instead.
  var byteArray = new Uint8Array(storedObject);
  return pouchdbBinaryUtils.blob([byteArray], {type: type});
}
github pouchdb / pouchdb / packages / node_modules / pouchdb-adapter-idb / src / blobSupport.js View on Github external
return new Promise(function (resolve) {
    var blob = createBlob(['']);
    var req = txn.objectStore(DETECT_BLOB_SUPPORT_STORE).put(blob, 'key');

    req.onsuccess = function () {
      var matchedChrome = navigator.userAgent.match(/Chrome\/(\d+)/);
      var matchedEdge = navigator.userAgent.match(/Edge\//);
      // MS Edge pretends to be Chrome 42:
      // https://msdn.microsoft.com/en-us/library/hh869301%28v=vs.85%29.aspx
      resolve(matchedEdge || !matchedChrome ||
        parseInt(matchedChrome[1], 10) >= 43);
    };

    req.onerror = txn.onabort = function (e) {
      // If the transaction aborts now its due to not being able to
      // write to the database, likely due to the disk being full
      e.preventDefault();
      e.stopPropagation();
github pouchdb / pouchdb / packages / node_modules / pouchdb-adapter-idb / src / utils.js View on Github external
function readBlobData(body, type, asBlob, callback) {
  if (asBlob) {
    if (!body) {
      callback(createBlob([''], {type: type}));
    } else if (typeof body !== 'string') { // we have blob support
      callback(body);
    } else { // no blob support
      callback(b64StringToBlob(body, type));
    }
  } else { // as base64 string
    if (!body) {
      callback('');
    } else if (typeof body !== 'string') { // we have blob support
      readAsBinaryString(body, function (binary) {
        callback(btoa(binary));
      });
    } else { // no blob support
      callback(body);
    }
  }
github pouchdb / pouchdb / packages / node_modules / pouchdb-ajax / src / request-browser.js View on Github external
xhr.onreadystatechange = function () {
    if (xhr.readyState !== 4) {
      return;
    }

    var response = {
      statusCode: xhr.status
    };

    if (xhr.status >= 200 && xhr.status < 300) {
      var data;
      if (options.binary) {
        data = createBlob([xhr.response || ''], {
          type: xhr.getResponseHeader('Content-Type')
        });
      } else {
        data = xhr.responseText;
      }
      callback(null, response, data);
    } else {
      var err = {};
      if (timedout) {
        err = new Error('ETIMEDOUT');
        err.code = 'ETIMEDOUT';
      } else if (typeof xhr.response === 'string' && xhr.response !== '') {
        try {
          err = JSON.parse(xhr.response);
        } catch (e) {}
      }
github stockulus / pouchdb-react-native / packages / pouchdb-adapter-leveldb-core-rn / lib / index-browser.js View on Github external
function createEmptyBlobOrBuffer(type) {
  return pouchdbBinaryUtils.blob([''], {type: type});
}
github pouchdb / pouchdb / packages / node_modules / pouchdb-ajax / src / createBlobOrBufferFromParts-browser.js View on Github external
function createBlobOrBufferFromParts(parts, type) {
  return createBlob(parts, {type: type});
}