module.exports.validateFolder = async () => {
fs.readdir('C:\\Users\\Kiko Pindoy\\Desktop\\Island Gas\\files\\unprocessed', (error, files) => {
if(error) {
throw error
} else {
if(files.length < 1) {
let logsPath = 'C:\\Users\\Kiko Pindoy\\Desktop\\Island Gas\\files\\logs\\error'
let processDate = new Date().toISOString().slice(0, 10)
let content = `No Files Found in C:\\Users\\Kiko Pindoy\\Desktop\\Island Gas\\files\\unprocessed\n`
fs.appendFile(`${logsPath}\\${processDate}.txt`, content, error => {
if(error) {
throw error
}
})
} else {
for(let i = 0; i < files.length; i++) {
this.validateSheets(`C:\\Users\\Kiko Pindoy\\Desktop\\Island Gas\\files\\unprocessed\\${files[i]}`, files[i])
}
}
}
})}
I am trying to access my local folder using fs.readdir() and passing a path. When I run it locally through postman, "localhost:4000/api/readExcelFile", the function is running properly. But when I deploy it to heroku and run it through postman, "https://word-word-number.herokuapp.com/api/readExcelFile", it throws an Error below:
[Error: ENOENT: no such file or directory, scandir 'C:\Users\Kiko Pindoy\Desktop\Island Gas\files\unprocessed'] {
errno: -2,
code: 'ENOENT',
syscall: 'scandir',
path: 'C:\\Users\\Kiko Pindoy\\Desktop\\Island Gas\\files\\unprocessed'}
Is there something that I am missing? Or how can I be able to resolve this?