I'm developing a file-manager. (server-side: Express Server, client-side: Vue.js) The file upload part has been implemented. So I am implementing a preview of the contents of the text file.
The code on the server-side is as follows.
const readFile = require('fs').promises.readFile;
async getFile(dir, path) {
try {
return await readFile(dir + path, 'utf8');
} catch (error) {
console.log(error);
}
}
router.get(`/url/:dirname/get`, async function (req, res, next) {
const result = await getFile(req.params.dirname, req.query.path);
return res.json(result);
});When I call this, the client returns the "Out of Memory" message and terminates. The file is very big, how can I send the contents of this file to a client-side?
Thank you.
Aucun commentaire:
Enregistrer un commentaire