I have a web application, which uses excel and word files to generate documentation, these files are stored on a local server, which is found on all network computers as a shared folder, at the time of deployment the application locally everything works correctly, but when I deploy it to a server in the cloud it stops working, the server tells me that it cannot find the excel and word files, according to me, it is because it is looking for the files in the same server in the cloud and not in the shared folder where they are stored.
Do you have any idea how I can fix this?
I share the code
Controller:
req.body.BD is equals to "K:/Compartida/INGRESOS/pr.xlsx"
const xlsx = require('xlsx');
const ExcelJS = require('exceljs');
const controlador = {};
controlador.Add = async (req, res) => {
//Here I receive the information of the front and save it in the excel file
const wb = new ExcelJS.Workbook();
wb.xlsx.readFile(req.body.BD)
.then(() => {
const ws = wb.getWorksheet(req.body.SheetName);
ws.addRow(req.body.datos);
wb.xlsx.writeFile(req.body.BD).then(() => {
res.status(200).json({ Message: "Guardado exitoso" });
});
}).
catch((error) => {
res.status(500).json({ Message: "Ocurrio un error", error });
});
};
controlador.Edit = async (req, res) => {
const wb = new ExcelJS.Workbook();
wb.xlsx.readFile(req.body.BD)
.then(() => {
const ws = wb.getWorksheet(req.body.SheetName);
ws.eachRow((data) => {
for (let j = 0; j < req.body.datos.length; j++) {
if (data.getCell(1).value === req.body.datos[j][0]) {
for (let i = 2; i <= data.cellCount; i++) {
data.getCell(i).value = req.body.datos[j][i - 1];
};
};
};
});
wb.xlsx.writeFile(req.body.BD);
res.status(200).json({ Message: "Guardado exitoso" });
}).catch((error) => {
res.status(500).json({ Message: "Ocurrio un error", error });
});
};
controlador.GetAll = async (req, res) => {
try {
const wb = xlsx.readFile(req.body.BD, { cellDates: true, sheetRows: false });
const ws = wb.Sheets[req.body.SheetName];
const data = xlsx.utils.sheet_to_json(ws);
res.status(200).json({ data });
} catch (error) {
res.status(500).json({ Message: "Ocurrio un error", error });
};
};
module.exports = controlador;