lib/upload.js
function uploadDirectory(aws, bucketName, clientRoot, headerSpec, orderSpec, keyPrefix) {
  const allFiles = getFileList(clientRoot);

  const filesGroupedByOrder = groupFilesByOrder(allFiles, orderSpec);

  return filesGroupedByOrder.reduce((existingUploads, files) => {
    return existingUploads.then(existingResults => {
      const uploadList = buildUploadList(files, clientRoot, headerSpec, keyPrefix);

      return Promise.all(
        uploadList.map(u => uploadFile(aws, bucketName, u.filePath, u.fileKey, u.headers))
      ).then(currentResults => existingResults.concat(currentResults));
    });
  }, Promise.resolve([]));
}
function uploadDirectory(aws, bucketName, clientRoot, headerSpec, orderSpec, keyPrefix) {
  const allFiles = getFileList(clientRoot);

  const filesGroupedByOrder = groupFilesByOrder(allFiles, orderSpec);

  return filesGroupedByOrder.reduce((existingUploads, files) => {
    return existingUploads.then(existingResults => {
      const uploadList = buildUploadList(files, clientRoot, headerSpec, keyPrefix);

      return Promise.all(
        uploadList.map(u => uploadFile(aws, bucketName, u.filePath, u.fileKey, u.headers))
      ).then(currentResults => existingResults.concat(currentResults));
    });
  }, Promise.resolve([]));
}
function uploadDirectory ( aws , bucketName , clientRoot , headerSpec , orderSpec , keyPrefix ) { const allFiles = getFileList ( clientRoot ) ; const filesGroupedByOrder = groupFilesByOrder ( allFiles , orderSpec ) ; return filesGroupedByOrder . reduce ( ( existingUploads , files ) => { return existingUploads . then ( existingResults => { const uploadList = buildUploadList ( files , clientRoot , headerSpec , keyPrefix ) ; return Promise . all ( uploadList . map ( u => uploadFile ( aws , bucketName , u . filePath , u . fileKey , u . headers ) ) ) . then ( currentResults => existingResults . concat ( currentResults ) ) ; } ) ; } , Promise . resolve ( [ ] ) ) ; }
Uploads client files to an S3 bucket
@param {Object} aws - AWS class
@param {string} bucketName - Name of bucket to be configured
@param {string} clientRoot - Full path to the root directory of client files
@param {Object[]} headerSpec - Array of header values to add to files
@param {string[]} orderSpec - Array of regex's to order upload by
@param {string} keyPrefix - A prefix for all files uploaded
Uploads client files to an S3 bucket