kunalSBasic opened a new issue, #623:
URL: https://github.com/apache/cordova-plugin-file/issues/623

   # Bug Report
   
   ## Problem
   I'm encountering an issue with the cordova-plugin-file plugin in iOS when 
trying to download and save a PDF file from an API response. The plugin seems 
to be working fine in Android, but I'm facing difficulties in iOS.
   
   ### What is expected to happen?
   The PDF file should be successfully downloaded and saved to the device's 
filesystem in iOS, similar to how it's functioning in Android.
   
   
   ### What does actually happen?
   Code runs successfully and falls under the success block and even present 
the toast of 'File downloaded successfully.' But file is not downloaded on 
device.
   
   
   ## Information
   <!-- Include all relevant information that might help understand and 
reproduce the problem -->
   
   
   
   ### Command or Code
   <!-- What command or code is needed to reproduce the problem? -->
   
    ```
    downloadPdfMobile(base64Data, fileName) {
       const folderPath = this.platform.is('android')
         ? this.file.externalRootDirectory + 'Download/'
         : this.file.documentsDirectory;
   
       console.log(folderPath, 'FOLDERPATH');
   
       // Convert base64 to Blob
       const byteCharacters = atob(base64Data);
       const byteNumbers = new Array(byteCharacters.length);
       for (let i = 0; i < byteCharacters.length; i++) {
         byteNumbers[i] = byteCharacters.charCodeAt(i);
       }
       const byteArray = new Uint8Array(byteNumbers);
       const blob = new Blob([byteArray], { type: 'application/pdf' });
   
       // Write the file
       this.file
         .writeFile(folderPath, fileName, blob, {
           replace: true,
         })
         .then(() => {
           this.presentToast('File downloaded successfully.');
           console.log('File downloaded successfully.');
         })
         .catch((error) => {
           this.presentToast('Error while downloading the file:');
           console.error('Error while downloading the file:', error);
         });
     }
   ```
   
   
   ### Environment, Platform, Device
   <!-- In what environment, on what platform or on which device are you 
experiencing the issue? -->
   
   
   
   ### Version information
   <!-- 
   What are relevant versions you are using?
   For example:
   Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins 
   Other Frameworks: Ionic Framework and CLI version
   Operating System, Android Studio, Xcode etc.
   -->
   Cordova Version: 12.0.0
   
   
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [x] I searched for existing GitHub issues
   - [x] I updated all Cordova tooling to most recent version
   - [x] I included all the necessary information above
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to