How to use the blob-util.createObjectURL 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 processing / p5.js-web-editor / client / modules / IDE / actions / files.js View on Github external
export function getBlobUrl(file) {
  if (file.blobUrl) {
    blobUtil.revokeObjectURL(file.blobUrl);
  }

  const fileBlob = blobUtil.createBlob([file.content], { type: 'text/plain' });
  const blobURL = blobUtil.createObjectURL(fileBlob);
  return blobURL;
}
github morkro / happy-plants / src / utils / blob.js View on Github external
return new Promise((resolve, reject) => {
    if (!isBlobbable(file) && !hasReaderSupport) {
      reject(new Error('File is not a blob'))
    }

    const canvas = document.createElement('canvas')
    const ctx = canvas.getContext('2d')
    const img = new Image()

    img.src = blobUtil.createObjectURL(file)
    img.onload = () => {
      const width = img.width
      const height = img.height
      const resizedWidth = options.width ? Math.ceil(options.width) : width / 2
      const resizedHeight = Math.ceil(height * resizedWidth / width)

      canvas.width = width
      canvas.height = height

      ctx.drawImage(img, 0, 0)

      blobUtil.canvasToBlob(hermiteResize(canvas, width, height, resizedWidth, resizedHeight))
        .then(blob => {
          blobUtil.revokeObjectURL(img.src)
          resolve(blob)
        })
github morkro / happy-plants / src / utils / blob.js View on Github external
export function getUrlFromBlob (blob) {
  return isBlobbable(blob)
    ? blobUtil.createObjectURL(blob)
    : ''
}