Skip to content

Commit

Permalink
Improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
manjufy committed Aug 13, 2017
1 parent b047296 commit b8c7242
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ var cmd = require('node-cmd');
var mkdirp = require('mkdirp')

exports.save = function (req, res) {
const video = req.files[ 0 ]
const video = req.files[0]

// check file
// write file
async.waterfall([
function (cb) {
function (callback) {
fs.readFile(video.path, (error, result) => {
if (error) {
console.log('ReadError:', error)
} else {
cb(null, result)
return callback(null, result)
}
})
},
function (result, cb) {
function (result, callback) {
const videoStoragePath = __dirname + '/videos/'
// create directory if does not exists
mkdirp(videoStoragePath, function (error) {
Expand All @@ -29,12 +29,12 @@ exports.save = function (req, res) {
if (error) {
console.log('WriteError:', error)
} else {
cb(null, 'success')
return callback(null, 'success')
}
})
})
}
])

console.log('COMPLETED!')
res.send('success')
}

0 comments on commit b8c7242

Please sign in to comment.