diff --git a/libs/common/src/platform/services/file-upload/bitwarden-file-upload.service.ts b/libs/common/src/platform/services/file-upload/bitwarden-file-upload.service.ts index 3d0c31ef3e..9a7b9a8982 100644 --- a/libs/common/src/platform/services/file-upload/bitwarden-file-upload.service.ts +++ b/libs/common/src/platform/services/file-upload/bitwarden-file-upload.service.ts @@ -8,23 +8,22 @@ export class BitwardenFileUploadService { apiCall: (fd: FormData) => Promise, ) { const fd = new FormData(); - try { - const blob = new Blob([encryptedFileData.buffer], { type: "application/octet-stream" }); - fd.append("data", blob, encryptedFileName); - } catch (e) { - if (Utils.isNode && !Utils.isBrowser) { + + if (Utils.isBrowser) { + const blob = new Blob([encryptedFileData.buffer], { type: "application/octet-stream" }); + fd.append("data", blob, encryptedFileName); + } else if (Utils.isNode) { fd.append( "data", Buffer.from(encryptedFileData.buffer) as any, { - filepath: encryptedFileName, + filename: encryptedFileName, contentType: "application/octet-stream", } as any, ); } else { - throw e; + throw new Error("Unsupported environment"); } - } await apiCall(fd); }