New max limit for files
This commit is contained in:
parent
1cf83c2485
commit
6d98014ad2
@ -49,12 +49,11 @@ self.addEventListener("message", function(e) {
|
||||
*/
|
||||
self.loadFile = function(file, inputNum) {
|
||||
const reader = new FileReader();
|
||||
let data;
|
||||
try {
|
||||
data = new Uint8Array(file.size);
|
||||
} catch (err) {
|
||||
self.port.postMessage({"error": err, "inputNum": inputNum});
|
||||
if (file.size >= 256*256*256*127) {
|
||||
self.port.postMessage({"error": "File size too large.", "inputNum": inputNum, "id": self.id});
|
||||
return;
|
||||
}
|
||||
const data = new Uint8Array(file.size);
|
||||
let offset = 0;
|
||||
const CHUNK_SIZE = 10485760; // 10MiB
|
||||
|
||||
@ -63,7 +62,7 @@ self.loadFile = function(file, inputNum) {
|
||||
self.port.postMessage({"fileBuffer": data.buffer, "inputNum": inputNum, "id": self.id}, [data.buffer]);
|
||||
return;
|
||||
}
|
||||
// self.port.postMessage({"progress": Math.round(offset / file.size * 100), "inputNum": inputNum});
|
||||
self.port.postMessage({"progress": Math.round(offset / file.size * 100), "inputNum": inputNum});
|
||||
const slice = file.slice(offset, offset + CHUNK_SIZE);
|
||||
reader.readAsArrayBuffer(slice);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user