lib/middleware/submissions.js
function getRequestFileParameters(req, res, next) {
  //A valid getForms request must have an appId parameter set
  var submitFileParams = {};
  submitFileParams.fileDetails = {};

  //Get the content body for normal parameter
  var filesInRequest = req.files;

  if (_.size(filesInRequest) === 0) {
    logger.error("Middleware: getRequestFileParameters, Expected A File To Have Been Sent ", {params: req.params});
    return next(new Error("Expected A File To Have Been Submitted"));
  }

  var fileDetails = _.map(filesInRequest, function(fileValue) {
    return fileValue;
  });

  fileDetails = _.first(fileDetails);

  logger.debug("Middleware: getRequestFileParameters ", {fileDetails: fileDetails, body: req.body});

  submitFileParams.fileDetails = {
    fileStream: fileDetails.path,
    fileName: fileDetails.originalname || fileDetails.name,
    fileType: fileDetails.mimetype,
    fileSize: fileDetails.size
  };

  req.appformsResultPayload = {
    data: submitFileParams,
    type: constants.resultTypes.submissions
  };

  logger.debug("Middleware: getRequestFileParameters ", {params: req.appformsResultPayload});

  return next();
}
function getRequestFileParameters(req, res, next) {
  //A valid getForms request must have an appId parameter set
  var submitFileParams = {};
  submitFileParams.fileDetails = {};

  //Get the content body for normal parameter
  var filesInRequest = req.files;

  if (_.size(filesInRequest) === 0) {
    logger.error("Middleware: getRequestFileParameters, Expected A File To Have Been Sent ", {params: req.params});
    return next(new Error("Expected A File To Have Been Submitted"));
  }

  var fileDetails = _.map(filesInRequest, function(fileValue) {
    return fileValue;
  });

  fileDetails = _.first(fileDetails);

  logger.debug("Middleware: getRequestFileParameters ", {fileDetails: fileDetails, body: req.body});

  submitFileParams.fileDetails = {
    fileStream: fileDetails.path,
    fileName: fileDetails.originalname || fileDetails.name,
    fileType: fileDetails.mimetype,
    fileSize: fileDetails.size
  };

  req.appformsResultPayload = {
    data: submitFileParams,
    type: constants.resultTypes.submissions
  };

  logger.debug("Middleware: getRequestFileParameters ", {params: req.appformsResultPayload});

  return next();
}
function getRequestFileParameters ( req , res , next ) { //A valid getForms request must have an appId parameter set var submitFileParams = { } ; submitFileParams . fileDetails = { } ; //Get the content body for normal parameter var filesInRequest = req . files ; if ( _ . size ( filesInRequest ) === 0 ) { logger . error ( "Middleware: getRequestFileParameters, Expected A File To Have Been Sent " , { params : req . params } ) ; return next ( new Error ( "Expected A File To Have Been Submitted" ) ) ; } var fileDetails = _ . map ( filesInRequest , function ( fileValue ) { return fileValue ; } ) ; fileDetails = _ . first ( fileDetails ) ; logger . debug ( "Middleware: getRequestFileParameters " , { fileDetails : fileDetails , body : req . body } ) ; submitFileParams . fileDetails = { fileStream : fileDetails . path , fileName : fileDetails . originalname || fileDetails . name , fileType : fileDetails . mimetype , fileSize : fileDetails . size } ; req . appformsResultPayload = { data : submitFileParams , type : constants . resultTypes . submissions } ; logger . debug ( "Middleware: getRequestFileParameters " , { params : req . appformsResultPayload } ) ; return next ( ) ; }
Middleware For Populating File Parameters From A Multipart Request

Used For Updating Submission Files
@param req
@param res
@returns next
Middleware For Populating File Parameters From A Multipart Request