Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript buffer to file

  function bufferToFile(
    buffer,
    filename,
    type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
  ) {
    let blob = new Blob([buffer], { type });
    const anchor = document.createElement('a');
    const url = URL.createObjectURL(blob);
    anchor.href = url;
    anchor.download = filename;
    document.body.appendChild(anchor);
    anchor.click();
    document.body.removeChild(anchor);
    URL.revokeObjectURL(url);
  }
Source by nodejs.org #
 
PREVIOUS NEXT
Tagged: #javascript #buffer #file
ADD COMMENT
Topic
Name
4+8 =