When uploading files with Sails JS the server crashes if there is no file sent with the request, considering this to be the controller action:
function(req, res) {
req.file('testFile').upload(function() {
// do something...
});
}
I have tried to check the headers, but there seems to be no difference between a file being sent or not.
I am looking for something like this:
function(req, res) {
if(file sent) {
req.file('testFile').upload(...);
} else {
// file was not sent, do something else
}
}
Is there a way that I could achieve this behavior of uploading a file or not on the same API?
I think this is what you're looking for