[PM-13923] [CLI] fix: resolve CLI file upload issue in Node.js 18+ (#11652)
* fix: resolve CLI file upload issue in Node.js 18+ * remove useless try catch Signed-off-by: xinghejd <31512683+xinghejd@users.noreply.github.com> --------- Signed-off-by: xinghejd <31512683+xinghejd@users.noreply.github.com> Co-authored-by: Andreas Coroiu <acoroiu@bitwarden.com>
This commit is contained in:
parent
4c43c72dca
commit
35764b53dc
|
@ -8,22 +8,21 @@ export class BitwardenFileUploadService {
|
|||
apiCall: (fd: FormData) => Promise<any>,
|
||||
) {
|
||||
const fd = new FormData();
|
||||
try {
|
||||
|
||||
if (Utils.isBrowser) {
|
||||
const blob = new Blob([encryptedFileData.buffer], { type: "application/octet-stream" });
|
||||
fd.append("data", blob, encryptedFileName);
|
||||
} catch (e) {
|
||||
if (Utils.isNode && !Utils.isBrowser) {
|
||||
} 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);
|
||||
|
|
Loading…
Reference in New Issue