Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement