mirror of
https://gitlab.com/timvisee/send.git
synced 2025-12-07 06:30:53 +03:00
added functionality to cancel uploads
This commit is contained in:
@@ -8,6 +8,7 @@ class FileSender extends EventEmitter {
|
||||
super();
|
||||
this.file = file;
|
||||
this.iv = window.crypto.getRandomValues(new Uint8Array(12));
|
||||
this.uploadXHR = new XMLHttpRequest();
|
||||
}
|
||||
|
||||
static delete(fileId, token) {
|
||||
@@ -35,6 +36,10 @@ class FileSender extends EventEmitter {
|
||||
});
|
||||
}
|
||||
|
||||
cancel() {
|
||||
this.uploadXHR.abort();
|
||||
}
|
||||
|
||||
upload() {
|
||||
const self = this;
|
||||
self.emit('loading', true);
|
||||
@@ -103,7 +108,7 @@ class FileSender extends EventEmitter {
|
||||
const fd = new FormData();
|
||||
fd.append('data', blob, file.name);
|
||||
|
||||
const xhr = new XMLHttpRequest();
|
||||
const xhr = self.uploadXHR;
|
||||
|
||||
xhr.upload.addEventListener('progress', e => {
|
||||
if (e.lengthComputable) {
|
||||
|
||||
Reference in New Issue
Block a user