How to use the pouchdb-binary-utils.base64StringToBlobOrBuffer 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-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 stockulus / pouchdb-react-native / packages / pouchdb-adapter-asyncstorage / src / inline_attachments.js View on Github external
Object.keys(doc._attachments).forEach(key => {
          const newAttachment = {
            ...attachmentObj[doc._attachments[key].digest]
          }
          if (newAttachment) {
            doc._attachments[key] = newAttachment
            if (binaryAttachments) {
              const contentType = doc._attachments[key].content_type
              doc._attachments[key].data = base64StringToBlobOrBuffer(
                doc._attachments[key].data,
                contentType
              )
            }
          }
        })
    })
github pouchdb / pouchdb / packages / node_modules / pouchdb-abstract-mapreduce / src / index.js View on Github external
Object.keys(atts).forEach(function (filename) {
        var att = atts[filename];
        atts[filename].data = b64ToBluffer(att.data, att.content_type);
      });
    });
github stockulus / pouchdb-react-native / packages / pouchdb-adapter-asyncstorage / src / get_attachment.js View on Github external
db.storage.get(forAttachment(digest), (error, attachmentData) => {
    if (error) {
      return callback(
        createError(MISSING_DOC, error.message || 'missing-read-error')
      )
    }

    const data = attachmentData.data
    if (opts.binary) {
      callback(null, base64StringToBlobOrBuffer(data, type))
    } else {
      callback(null, data)
    }
  })
}
github pouchdb / pouchdb / packages / node_modules / pouchdb-adapter-http / src / index.js View on Github external
Object.keys(atts).forEach(function (filename) {
    var att = atts[filename];
    att.data = b64StringToBluffer(att.data, att.content_type);
  });
}