SHARE
TWEET

Untitled

a guest Oct 18th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     only deals with 64bit files and PDF, DOCX type of files.
  3.     TODO: check if arguments is passed into the function
  4. */
  5.  
  6. function createUrlFromBase64(file, type) {    
  7.     let FILE_TYPE;
  8.     let BASE = 'base64';
  9.  
  10.     switch (type) {
  11.         case 'pdf':
  12.             FILE_TYPE = 'data:application/pdf';
  13.             break;
  14.         case 'docx':    
  15.             FILE_TYPE = 'data:application/vnd.openxmlformats-officedocument.wordprocessingml.document';
  16.             break;
  17.         default:
  18.             break;
  19.     }
  20.     return `data:application/${FILE_TYPE};${BASE},${file}`
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top