diff --git a/server/server.mjs b/server/server.mjs index aa741c3..39e3ca0 100644 --- a/server/server.mjs +++ b/server/server.mjs @@ -119,18 +119,23 @@ const uploadToB2 = async (data, bucketId, fileName) => { if (!hasB2) { return; } - const uploadUrl = await b2.getUploadUrl({ - bucketId, - }); - - const upload = await b2.uploadFile({ - uploadUrl, - uploadAuthToken: uploadUrl.data.authorizationToken, - fileName, - data, - }); - - return upload; + try { + const uploadUrlResponse = await b2.getUploadUrl({ + bucketId, + }); + + const upload = await b2.uploadFile({ + uploadUrl: uploadUrlResponse.data.uploadUrl, + uploadAuthToken: uploadUrlResponse.data.authorizationToken, + fileName, + data, + }); + + return upload; + } catch (error) { + console.error("Error in uploadToB2:", error); + throw error; + } }; const m = multer();