docs: function writeStreamToFile(fileMeta, stream) {
    var deferred = q.defer();
    stream.on('end', function() {
      deferred.resolve(fileMeta);
    });
    stream.on('error', function(error) {
      deferred.reject(error);
    });
    var filename = imageDir + '/' + fileMeta.uid;
    stream.pipe(fs.createWriteStream(filename));
    return deferred.promise;
  }