forked from mystiq/hydrogen-web
track upload error
This commit is contained in:
parent
91f15074be
commit
48cd4ac95d
1 changed files with 26 additions and 12 deletions
|
@ -29,6 +29,7 @@ export class AttachmentUpload {
|
|||
this._uploadPromise = null;
|
||||
this._uploadRequest = null;
|
||||
this._aborted = false;
|
||||
this._error = null;
|
||||
}
|
||||
|
||||
upload() {
|
||||
|
@ -39,8 +40,9 @@ export class AttachmentUpload {
|
|||
}
|
||||
|
||||
async _upload() {
|
||||
try {
|
||||
let transferredBlob = this._unencryptedBlob;
|
||||
if (this.isEncrypted) {
|
||||
if (this._isEncrypted) {
|
||||
const {info, blob} = await encryptAttachment(this._platform, this._unencryptedBlob);
|
||||
transferredBlob = blob;
|
||||
this._encryptionInfo = info;
|
||||
|
@ -52,6 +54,14 @@ export class AttachmentUpload {
|
|||
const {content_uri} = await this._uploadRequest.response();
|
||||
this._mxcUrl = content_uri;
|
||||
this._transferredBlob = transferredBlob;
|
||||
} catch (err) {
|
||||
this._error = err;
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
get isUploaded() {
|
||||
return !!this._transferredBlob;
|
||||
}
|
||||
|
||||
/** @public */
|
||||
|
@ -65,6 +75,10 @@ export class AttachmentUpload {
|
|||
return this._unencryptedBlob;
|
||||
}
|
||||
|
||||
get error() {
|
||||
return this._error;
|
||||
}
|
||||
|
||||
/** @package */
|
||||
uploaded() {
|
||||
if (!this._uploadPromise) {
|
||||
|
|
Loading…
Reference in a new issue