mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-15 04:15:28 +03:00
don't allow reading files bigger then 1MB
This commit is contained in:
parent
957e1d3bd4
commit
10caea40d4
1 changed files with 30 additions and 24 deletions
|
@ -114,11 +114,16 @@ function configuration_restore() {
|
||||||
chosenFileEntry.file(function(file) {
|
chosenFileEntry.file(function(file) {
|
||||||
var reader = new FileReader();
|
var reader = new FileReader();
|
||||||
|
|
||||||
reader.onerror = function (e) {
|
reader.onprogress = function(e) {
|
||||||
console.error(e);
|
if (e.total > 1048576) { // 1 MB
|
||||||
|
// dont allow reading files bigger then 1 MB
|
||||||
|
console.log('File limit (1 MB) exceeded, aborting');
|
||||||
|
reader.abort();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
reader.onloadend = function(e) {
|
reader.onloadend = function(e) {
|
||||||
|
if (e.total != 0 && e.total == e.loaded) {
|
||||||
console.log('Read SUCCESSFUL');
|
console.log('Read SUCCESSFUL');
|
||||||
|
|
||||||
try { // check if string provided is a valid JSON
|
try { // check if string provided is a valid JSON
|
||||||
|
@ -143,6 +148,7 @@ function configuration_restore() {
|
||||||
|
|
||||||
// all of the arrays/objects are set, upload changes
|
// all of the arrays/objects are set, upload changes
|
||||||
configuration_upload();
|
configuration_upload();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
reader.readAsText(file);
|
reader.readAsText(file);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue