+ Videos.add(videoData, function (err) {
+ if (err) {
+ // TODO unseed the video
+ logger.error('Cannot insert this video in the database.')
+ return next(err)
+ }
+
+ fs.readFile(thumbnailsDir + thumbnailName, function (err, data) {
+ if (err) {
+ // TODO: remove video?
+ logger.error('Cannot read the thumbnail of the video')
+ return next(err)
+ }
+
+ // Set the image in base64
+ videoData.thumbnailBase64 = new Buffer(data).toString('base64')
+ // Now we'll add the video's meta data to our friends
+ friends.addVideoToFriends(videoData)
+
+ // TODO : include Location of the new video -> 201
+ res.type('json').status(204).end()
+ })
+ })