mercredi 27 mai 2015

How to use multer to upload files to different servers

    app.use(multer({
  dest: './uploads/',
  rename: function (fieldname, filename,req,res) {
    logger.debug('req>>>>>>>>>>>>>>>>>>>>> ' + req);
    logger.debug(req.body);
    logger.debug('res>>>>>>>>>>>>>>>>>>>>> ' + res);
   // logger.debug(res);
    return filename.replace(/\W+/g, '-').toLowerCase() + Date.now()
  },
  limits: {
    fieldNameSize: 999999999,
    fieldSize: 999999999
  },
  includeEmptyFields: true,
  inMemory: false,
  onFileUploadStart: function(file) {
  //  console.log('Starting ' + file.fieldname);
    logger.debug('Starting ' + file.fieldname);
  },
  onFileUploadData: function(file, data) {
   // console.log('Got a chunk of data!');
    logger.debug('Got a chunk of data!');
  },
  onFileUploadComplete: function(file) {
   // console.log('Completed file!');
    logger.debug('Completed file!');
     done=true;
  },
  onParseStart: function() {
    //console.log('Starting to parse request!');
    logger.debug('Starting to parse request!');
  },
  onParseEnd: function(req, next) {
    //console.log('Done parsing!');
    logger.debug('Done parsing!');

    done = true;
    next();
  },
  onError: function(e, next) {
    if (e) {
      //console.log(e.stack);
      logger.debug(e.stack);
    }
    next();
  }
   }));

How do i upload files from ec2 to s3 on amazon AWS I am using angular for the frontend and node js as backend. I deployed code in amazon AWS. Is there any option to upload files in AWS server




Aucun commentaire:

Enregistrer un commentaire