maksymov commented on issue #364: Large file save freeze app for seconds
URL: 
https://github.com/apache/cordova-plugin-file/issues/364#issuecomment-612796542
 
 
   I have `<input type='file'>` in my form. Now I want to save selected file in 
`LocalFileSystem.PERSISTENT`.
   
   My code for that:
   
   ```javascript
   self.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fs) {
     fs.root.getFile(file_name, { create: true, exclusive: false }, function 
(fileEntry) {
       var reader = new FileReader();
       reader.onloadend = function () {
         fileEntry.createWriter(function (fileWriter) {
           fileWriter.onwriteend = function () {};
           fileWriter.onerror = function (e) {};
           dataObj = new Blob([reader.result], { type: 'text/plain' });
           // freeze here
           fileWriter.write(dataObj);
           postMessage('ok');
         });
       };
       reader.readAsDataURL($(file_id)[0].files[0]);
     }, onErrorCreateFile);
   }, onErrorLoadFs);
   ```
   
   But this code freeze my UI on device (ios, android) up to 10 seconds when 
file is 30MB. I discovered the world of **Web Workers**, but there is no access 
to `LocalFileSystem`.
   
   How can I save selected file (`<input type='file'>`) to my `LocalFileSystem` 
without UI freezes?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to