Remove ReadChunkFromFile
parent
38212521af
commit
a8bbd8623b
|
@ -41,7 +41,6 @@ class Uploader {
|
|||
this.Key = data.key;
|
||||
this.GetChunks();
|
||||
for (let chunk of this.Chunks) {
|
||||
let dataChunk = yield this.ReadChunkFromFile(this.File, chunk);
|
||||
let formData = new FormData();
|
||||
formData.append('file', this.File.slice(chunk.Start, chunk.End));
|
||||
formData.append('start', chunk.Start.toString());
|
||||
|
@ -58,17 +57,6 @@ class Uploader {
|
|||
}
|
||||
});
|
||||
}
|
||||
ReadChunkFromFile(file, chunk) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let reader = new FileReader();
|
||||
let blob = this.File.slice(chunk.Start, chunk.End);
|
||||
reader.onload = () => {
|
||||
resolve(reader.result);
|
||||
};
|
||||
reader.onerror = reject;
|
||||
reader.readAsArrayBuffer(blob);
|
||||
});
|
||||
}
|
||||
GetChunks() {
|
||||
for (let currentChunk = 1; currentChunk <= this.TotalChunks; currentChunk++) {
|
||||
let start = (currentChunk - 1) * this.MaxChunkSize;
|
||||
|
|
|
@ -54,8 +54,6 @@ class Uploader {
|
|||
this.GetChunks();
|
||||
|
||||
for (let chunk of this.Chunks) {
|
||||
let dataChunk = await this.ReadChunkFromFile(this.File, chunk);
|
||||
|
||||
let formData = new FormData();
|
||||
|
||||
formData.append('file', this.File.slice(chunk.Start, chunk.End));
|
||||
|
@ -76,21 +74,6 @@ class Uploader {
|
|||
}
|
||||
}
|
||||
|
||||
ReadChunkFromFile(file: File, chunk: Chunk): Promise<string | ArrayBuffer> {
|
||||
return new Promise((resolve, reject) => {
|
||||
let reader = new FileReader();
|
||||
let blob = this.File.slice(chunk.Start, chunk.End);
|
||||
|
||||
reader.onload = () => {
|
||||
resolve(reader.result);
|
||||
}
|
||||
|
||||
reader.onerror = reject;
|
||||
|
||||
reader.readAsArrayBuffer(blob);
|
||||
});
|
||||
}
|
||||
|
||||
GetChunks() {
|
||||
for (let currentChunk = 1; currentChunk <= this.TotalChunks; currentChunk++) {
|
||||
let start = (currentChunk - 1) * this.MaxChunkSize;
|
||||
|
|
Loading…
Reference in New Issue