show error page if upload fails
This commit is contained in:
parent
cbd1daca1e
commit
63fe2c7099
|
@ -51,6 +51,9 @@ class FileSender extends EventEmitter {
|
||||||
reader.onload = function(event) {
|
reader.onload = function(event) {
|
||||||
resolve(new Uint8Array(this.result));
|
resolve(new Uint8Array(this.result));
|
||||||
};
|
};
|
||||||
|
reader.onerror = function(event) {
|
||||||
|
reject(event.explicitOriginalTarget.error.name);
|
||||||
|
};
|
||||||
})
|
})
|
||||||
])
|
])
|
||||||
.then(([secretKey, plaintext]) => {
|
.then(([secretKey, plaintext]) => {
|
||||||
|
|
|
@ -12,6 +12,7 @@ $(document).ready(function() {
|
||||||
$('#file-list').show();
|
$('#file-list').show();
|
||||||
$('#upload-progress').hide();
|
$('#upload-progress').hide();
|
||||||
$('#share-link').hide();
|
$('#share-link').hide();
|
||||||
|
$('#upload-error').hide();
|
||||||
|
|
||||||
if (localStorage.length === 0) {
|
if (localStorage.length === 0) {
|
||||||
toggleHeader();
|
toggleHeader();
|
||||||
|
@ -46,6 +47,7 @@ $(document).ready(function() {
|
||||||
$('#file-list').show();
|
$('#file-list').show();
|
||||||
$('#upload-progress').hide();
|
$('#upload-progress').hide();
|
||||||
$('#share-link').hide();
|
$('#share-link').hide();
|
||||||
|
$('#upload-error').hide();
|
||||||
$copyBtn.attr('disabled', false);
|
$copyBtn.attr('disabled', false);
|
||||||
$copyBtn.html('Copy');
|
$copyBtn.html('Copy');
|
||||||
});
|
});
|
||||||
|
@ -66,6 +68,7 @@ $(document).ready(function() {
|
||||||
$('#page-one').hide();
|
$('#page-one').hide();
|
||||||
$('#file-list').hide();
|
$('#file-list').hide();
|
||||||
$('#upload-progress').show();
|
$('#upload-progress').show();
|
||||||
|
$('#upload-error').hide();
|
||||||
$('#upload-filename').innerHTML += file.name;
|
$('#upload-filename').innerHTML += file.name;
|
||||||
// update progress bar
|
// update progress bar
|
||||||
document
|
document
|
||||||
|
@ -73,28 +76,36 @@ $(document).ready(function() {
|
||||||
.style.setProperty('--progress', percentComplete + '%');
|
.style.setProperty('--progress', percentComplete + '%');
|
||||||
$('#progress-text').html(`${percentComplete}%`);
|
$('#progress-text').html(`${percentComplete}%`);
|
||||||
});
|
});
|
||||||
fileSender.upload().then(info => {
|
fileSender
|
||||||
const url = info.url.trim() + `#${info.secretKey}`.trim();
|
.upload()
|
||||||
$('#link').attr('value', url);
|
.then(info => {
|
||||||
const fileData = {
|
const url = info.url.trim() + `#${info.secretKey}`.trim();
|
||||||
name: file.name,
|
$('#link').attr('value', url);
|
||||||
fileId: info.fileId,
|
const fileData = {
|
||||||
url: info.url,
|
name: file.name,
|
||||||
secretKey: info.secretKey,
|
fileId: info.fileId,
|
||||||
deleteToken: info.deleteToken,
|
url: info.url,
|
||||||
creationDate: new Date(),
|
secretKey: info.secretKey,
|
||||||
expiry: expiration
|
deleteToken: info.deleteToken,
|
||||||
};
|
creationDate: new Date(),
|
||||||
localStorage.setItem(info.fileId, JSON.stringify(fileData));
|
expiry: expiration
|
||||||
|
};
|
||||||
|
localStorage.setItem(info.fileId, JSON.stringify(fileData));
|
||||||
|
|
||||||
$('#page-one').hide();
|
$('#page-one').hide();
|
||||||
$('#file-list').hide();
|
$('#file-list').hide();
|
||||||
$('#upload-progress').hide();
|
$('#upload-progress').hide();
|
||||||
$('#share-link').show();
|
$('#share-link').show();
|
||||||
|
$('#upload-error').hide();
|
||||||
|
|
||||||
populateFileList(JSON.stringify(fileData));
|
populateFileList(JSON.stringify(fileData));
|
||||||
notify('Your upload has finished.');
|
notify('Your upload has finished.');
|
||||||
});
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.log('Upload error name: ' + err);
|
||||||
|
$('#page-one').hide();
|
||||||
|
$('#upload-error').show();
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
window.allowDrop = function(ev) {
|
window.allowDrop = function(ev) {
|
||||||
|
|
|
@ -89,6 +89,17 @@
|
||||||
Send another file
|
Send another file
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="upload-error">
|
||||||
|
<div class="title">
|
||||||
|
Upload error<br>
|
||||||
|
This file cannot be uploaded!
|
||||||
|
</div>
|
||||||
|
<div class="send-new">
|
||||||
|
Send another file
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in New Issue