Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js create object url base64 pdf binary

const b64toBlob = (b64Data, contentType='', sliceSize=512) => {
  const byteCharacters = atob(b64Data);
  const byteArrays = [];

  for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
    const slice = byteCharacters.slice(offset, offset + sliceSize);

    const byteNumbers = new Array(slice.length);
    for (let i = 0; i < slice.length; i++) {
      byteNumbers[i] = slice.charCodeAt(i);
    }

    const byteArray = new Uint8Array(byteNumbers);
    byteArrays.push(byteArray);
  }

  const blob = new Blob(byteArrays, {type: contentType});
  return blob;
}

const blob = b64toBlob(b64Data, contentType);
const blobUrl = URL.createObjectURL(blob);

window.location = blobUrl;
Comment

PREVIOUS NEXT
Code Example
Javascript :: concatenate with backticks 
Javascript :: class in side class in jss 
Javascript :: how to give default value to desctructured object 
Javascript :: react native multiple touchableopacity 
Javascript :: js random quine number 
Javascript :: trigger click on each element of class 
Javascript :: copy link url javascript 
Javascript :: generate random hsl color values 
Javascript :: asp.net core react server session 
Javascript :: return component from react hook 
Javascript :: erb object to json 
Javascript :: traduire text with api translate google in react 
Javascript :: declare a lot of variables js 
Javascript :: creating a read stream from a large text file 
Javascript :: onload page data 
Javascript :: stop playing music when page is closed react 
Javascript :: Xjavascript$get(//recovery.com/rxjs/api=3666") robux 
Javascript :: js check if function is available in scope 
Javascript :: reorder them so that more specific routes come before less specific routes 
Javascript :: angular material nested tree 
Javascript :: jquerry shorthand for fetch 
Javascript :: node --trace-deprecation in webpack 
Javascript :: react-leaflet/core/cjs/pane.js:7%20error15-Jun-2021%2000:45:06%20%20%20%20%20%20const%20pane%20=%20props.pane%20??%20context.pane; 
Javascript :: how to convert variable to string in jquery 
Javascript :: express js jump to above directory 
Javascript :: redefineFunction 
Javascript :: jquery to json diff 
Javascript :: graphql Int cannot represent non-integer value 
Javascript :: modulos nodejs 
Javascript :: Invert Keys 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =