class.js
function(next) {
    var self = this;
    var obj                   = {};
    obj.path                  = path.join(os.tmpdir,  randomstring.generate());
    obj.original_name         = self.document[self.has_attached_file].original_url.split('/').pop();

    this.downloadUrl(self.document[self.has_attached_file].original_url, obj.path, function() {
      self.identify({input: obj.path}, function(err, identity) {
        fs.stat(obj.path, function(err, stats) {
          obj.file_size       = stats.size;
          obj.content_type    = 'image/'+identity.format.toLowerCase();
          next(err, obj);
        })      
      })
    });
  }
function(next) {
    var self = this;
    var obj                   = {};
    obj.path                  = path.join(os.tmpdir,  randomstring.generate());
    obj.original_name         = self.document[self.has_attached_file].original_url.split('/').pop();

    this.downloadUrl(self.document[self.has_attached_file].original_url, obj.path, function() {
      self.identify({input: obj.path}, function(err, identity) {
        fs.stat(obj.path, function(err, stats) {
          obj.file_size       = stats.size;
          obj.content_type    = 'image/'+identity.format.toLowerCase();
          next(err, obj);
        })      
      })
    });
  }
function ( next ) { var self = this ; var obj = { } ; obj . path = path . join ( os . tmpdir , randomstring . generate ( ) ) ; obj . original_name = self . document [ self . has_attached_file ] . original_url . split ( '/' ) . pop ( ) ; this . downloadUrl ( self . document [ self . has_attached_file ] . original_url , obj . path , function ( ) { self . identify ( { input : obj . path } , function ( err , identity ) { fs . stat ( obj . path , function ( err , stats ) { obj . file_size = stats . size ; obj . content_type = 'image/' + identity . format . toLowerCase ( ) ; next ( err , obj ) ; } ) } ) } ) ; }
this is currently not used.  It is to download a url that is saved to a model and download that file and prepare the parameters to save.  I am not sure where the best place to put this code, I was thinking of adding it to the middleware.
this is currently not used . It is to download a url that is saved to a model and download that file and prepare the parameters to save . I am not sure where the best place to put this code I was thinking of adding it to the middleware .