You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2020/04/13 07:58:40 UTC
[GitHub] [cordova-plugin-file] maksymov commented on issue #364: Large file
save freeze app for seconds
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:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org