title: How to save Blob in Ionic
body: <p>I am new to ionic framework, actually I am getting byte array as response from back end service and converting it to blob. How can I save it to PDF in ionic?</p>
  
  <pre><code>var blob = new Blob([res], { type: 'application/pdf' });
  </code></pre>
  
  <p>Here res is the response (byte array) from the service.</p>
  
  <p>Code</p>
  
  <pre><code>var blob = new Blob([res], { type: 'application/pdf' });         
  
          let fileName="Receipt.pdf";         
          let filePath = (this.platform.is('android')) ? 
          this.file.externalRootDirectory : this.file.cacheDirectory;
  
          this.file.writeFile(filePath, fileName, blob, { replace: true }).then((fileEntry) =&gt; {
  
            console.log("File created!");          
            this.fileOpener.open(fileEntry.toURL(), 'application/pdf')
              .then(() =&gt; console.log('File is opened'))
              .catch(err =&gt; console.error('Error openening file: ' + err));
          })
            .catch((err) =&gt; {
              console.error("Error creating file: " + err);
              throw err;  
            });
  </code></pre>
  
  <p>Thanks in advance.</p>