I have a very simple node.js app that will run in my computer in conjunction with a photo booth app. Basically the photo booth software snaps a photo and then saves it in a local folder in my computer.
In my node.js app I am using chokidar as a way to watch for changes in that images folder. So whenever a new image is added, the watcher detects it and this is where I want to upload the file to a remote server.
// Initialize watcher.
var watcher = chokidar.watch('./images', {
ignored: /[\/\\]\./,
persistent: true
});
watcher
.on('add', path => log(`File ${path} has been added`))
.on('change', path => log(`File ${path} has been changed`))
.on('unlink', path => log(`File ${path} has been removed`));
However, I am unsure on how to proceed the handling of the upload. Is there a way to get the path of this newly added image and pass it to another express middleware such as multer and then upload the image to the server? Can this be done?