title: Javascript How to convert Base 64 url to file?
body: <p>I am retriving file data from database, and I need to send to frontend (My frontend has download action to download the file) How to convert these type of url to file. I hope it can use in any file types (doc, txt, jpg, pdf, zip .....)</p>
  <pre><code>&quot;data:text/plain;charset=utf-8;base64,MzQuNjIzNjU...................&quot;
  </code></pre>
  <p>This is my implementation. It works on txt, but it does not work for jpg and other file types for some reasons.  Can any one help me to figure out this problem? (I think it might be the encoding or decoding problem)  Thanks :)</p>
  <pre><code>        let mime = file.url.split(',')[0].split(':')[1].split(';')[0];
          console.log(mime);
          let content = unescape(encodeURIComponent(file.url.split(',')[1]));
          content = Buffer.from(content, 'base64').toString();
  
          console.log(content);
  
          let temp = mime + &quot;;charset=UTF-8&quot;;
          res.set('Content-Type', temp);
          res.set('Content-Disposition','attachment; filename=' + file.name );
          res.send(content);
  </code></pre>