lib/cloud/services/fileService.js
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;
}
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;
}
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 ; }
Utility function for saving file in temp folder
@param fileMeta
@param stream
Utility function for saving file in temp folder