How to use the blob-util.blobToBase64String function in blob-util

To help you get started, we’ve selected a few blob-util 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 morkro / happy-plants / src / app / plant / store / actions / add.js View on Github external
async function addPlantLocalforage (state, meta) {
  // FIXME: This is generally a bad idea. Use feature detection instead.
  // However, I could not find a reliable way to test if IndexedDB supports blobs,
  // as it fails silently. We have to convert the blob to base64,
  // because mobile Safari 10 has a bug with storing Blobs in IndexedDB.

  if (iOS && !!meta.blob) {
    const base64String = await blobToBase64String(meta.blob)
    await addEntryLF(namespace + meta.guid, { ...meta, blob: base64String })
  } else {
    await addEntryLF(namespace + meta.guid, meta)
  }
}
github microblink / microblink-js / src / microblink.ts View on Github external
const qrCodeAsBase64 = await ScanExchangeHelper.generateQRCode(scanDocData.shortLink)
        scanDocData.qrCodeAsBase64 = qrCodeAsBase64
      }

      if (
        scanDocData.status === ScanExchangerCodes.Step07_ResultIsAvailable &&
        (scanDocData.result || scanDocData.resultUrl)
      ) {
        let scanResultDec
        if (scanDocData.result) {
          scanResultDec = CryptoHelper.decrypt(scanDocData.result, secretKey)
        } else if (scanDocData.resultUrl) {
          const resultUrl = CryptoHelper.decrypt(scanDocData.resultUrl, secretKey)
          const response = await fetch(resultUrl)
          const blob = await response.blob()
          const text = await blobToBase64String(blob)
          scanDocData.result = text
          scanResultDec = CryptoHelper.decrypt(text, secretKey)
          firebase
            .storage()
            .refFromURL(resultUrl)
            .delete()
        }
        // Notify success listeners
        this.notifyOnSuccessListeners({ result: scanResultDec, sourceBlob: null }, true)

        // After successfully read 'result', remove it from the Firestore
        scan.update({
          result: null,
          resultUrl: null
        })
github morkro / happy-plants / src / utils / blob.spec.js View on Github external
beforeAll(async () => {
    base64 = await blobUtil.blobToBase64String(blob)
  })
github microblink / microblink-js / src / microblink.ts View on Github external
return new Observable((observer: Observer) => {
      blobToBase64String(blob)
        .then(blobAsBase64String => {
          this.API.Recognize(this.recognizers, blobAsBase64String, uploadProgress).subscribe(
            result => {
              const output = { sourceBlob: blob, result: result }
              this.notifyOnSuccessListeners(output, isFileScan)
              observer.next(output)
              observer.complete()
            },
            err => {
              if (err) {
                this.notifyOnErrorListeners(err)
                observer.error(err)
              }
            }
          )
        })
github WorldBrain / Memex / src / pouchdb.js View on Github external
(doc && !get(['_attachments', attachmentId, 'digest'])(doc))
    ) {
        return undefined
    }
    let blobOrBuffer
    try {
        blobOrBuffer = await db.getAttachment(docId, attachmentId)
    } catch (err) {
        return undefined
    }
    const contentType = get(['_attachments', attachmentId, 'content_type'])(doc)
    const isBrowser = typeof window !== 'undefined' && !window.process
    const blob = isBrowser
        ? blobOrBuffer
        : await arrayBufferToBlob(blobOrBuffer, contentType)
    const base64 = await blobToBase64String(blob)
    const dataUrl = `data:${blob.type};base64,${base64}`
    return dataUrl
}