diff --git a/src/services/cipher.service.ts b/src/services/cipher.service.ts index 3b3e8a524f..2792c80581 100644 --- a/src/services/cipher.service.ts +++ b/src/services/cipher.service.ts @@ -631,7 +631,7 @@ export class CipherService implements CipherServiceAbstraction { try { const uploadDataResponse = await this.apiService.postCipherAttachment(cipher.id, request); response = admin ? uploadDataResponse.cipherMiniResponse : uploadDataResponse.cipherResponse; - this.fileUploadService.uploadCipherAttachment(admin, uploadDataResponse, filename, data); + await this.fileUploadService.uploadCipherAttachment(admin, uploadDataResponse, filename, data); } catch (e) { if (e instanceof ErrorResponse && (e as ErrorResponse).statusCode === 404 || (e as ErrorResponse).statusCode === 405) { response = await this.legacyServerAttachmentFileUpload(admin, cipher.id, encFileName, encData, dataEncKey[1]); diff --git a/src/services/fileUpload.service.ts b/src/services/fileUpload.service.ts index ba80932790..02db07163d 100644 --- a/src/services/fileUpload.service.ts +++ b/src/services/fileUpload.service.ts @@ -40,7 +40,7 @@ export class FileUploadService implements FileUploadServiceAbstraction { throw new Error('Unknown file upload type'); } } catch (e) { - this.apiService.deleteSend(uploadData.sendResponse.id); + await this.apiService.deleteSend(uploadData.sendResponse.id); throw e; } } @@ -59,16 +59,16 @@ export class FileUploadService implements FileUploadServiceAbstraction { uploadData.attachmentId); return renewalResponse.url; }; - this.azureFileUploadService.upload(uploadData.url, encryptedFileData, renewalCallback); + await this.azureFileUploadService.upload(uploadData.url, encryptedFileData, renewalCallback); break; default: throw new Error('Unknown file upload type.'); } } catch (e) { if (admin) { - this.apiService.deleteCipherAttachmentAdmin(response.id, uploadData.attachmentId); + await this.apiService.deleteCipherAttachmentAdmin(response.id, uploadData.attachmentId); } else { - this.apiService.deleteCipherAttachment(response.id, uploadData.attachmentId); + await this.apiService.deleteCipherAttachment(response.id, uploadData.attachmentId); } throw e; } diff --git a/src/services/send.service.ts b/src/services/send.service.ts index 5bfc3de68f..4f94762469 100644 --- a/src/services/send.service.ts +++ b/src/services/send.service.ts @@ -142,7 +142,7 @@ export class SendService implements SendServiceAbstraction { const uploadDataResponse = await this.apiService.postFileTypeSend(request); response = uploadDataResponse.sendResponse; - this.fileUploadService.uploadSendFile(uploadDataResponse, sendData[0].file.fileName, sendData[1]); + await this.fileUploadService.uploadSendFile(uploadDataResponse, sendData[0].file.fileName, sendData[1]); } catch (e) { if (e instanceof ErrorResponse && (e as ErrorResponse).statusCode === 404) { response = await this.legacyServerSendFileUpload(sendData, request);