function _uploadFile(incomingFd, incomingFileStream, handleProgress, s3ClientOpts, done) {
  // https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#upload-property
  var s3ManagedUpload = _buildS3Client(s3ClientOpts)
  .upload(_stripKeysWithUndefinedValues({
    Bucket: s3ClientOpts.bucket,
    Key: incomingFd.replace(/^\/+/, ''),//« remove any leading slashes
    Body: incomingFileStream,
    ContentType: mime.getType(incomingFd)//« advisory; makes things nicer in the S3 dashboard
  }), (err, rawS3ResponseData)=>{
    if (err) {
      return done(err);
    } else {
      return done(undefined, {
        rawS3ResponseData
      });
    }
  });//_∏_

  s3ManagedUpload.on('httpUploadProgress', (event)=>{
    // console.log('upload progress');
    let written = _.isNumber(event.loaded) ? event.loaded : 0;
    let total = _.isNumber(event.total) ? event.total : undefined;
    let handledSuccessfully = handleProgress(_stripKeysWithUndefinedValues({
      name: incomingFileStream.filename || incomingFd,
      fd: incomingFd,
      written,
      total,
      percent: total ? (written / total) : undefined
    }));
    if (!handledSuccessfully) {
      s3ManagedUpload.abort();
    }
  });//œ

}
function _uploadFile(incomingFd, incomingFileStream, handleProgress, s3ClientOpts, done) {
  
  var s3ManagedUpload = _buildS3Client(s3ClientOpts)
  .upload(_stripKeysWithUndefinedValues({
    Bucket: s3ClientOpts.bucket,
    Key: incomingFd.replace(/^\/+/, ''),
    Body: incomingFileStream,
    ContentType: mime.getType(incomingFd)
  }), (err, rawS3ResponseData)=>{
    if (err) {
      return done(err);
    } else {
      return done(undefined, {
        rawS3ResponseData
      });
    }
  });

  s3ManagedUpload.on('httpUploadProgress', (event)=>{
    
    let written = _.isNumber(event.loaded) ? event.loaded : 0;
    let total = _.isNumber(event.total) ? event.total : undefined;
    let handledSuccessfully = handleProgress(_stripKeysWithUndefinedValues({
      name: incomingFileStream.filename || incomingFd,
      fd: incomingFd,
      written,
      total,
      percent: total ? (written / total) : undefined
    }));
    if (!handledSuccessfully) {
      s3ManagedUpload.abort();
    }
  });

}
function _uploadFile ( incomingFd , incomingFileStream , handleProgress , s3ClientOpts , done ) { // https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#upload-property var s3ManagedUpload = _buildS3Client ( s3ClientOpts ) . upload ( _stripKeysWithUndefinedValues ( { Bucket : s3ClientOpts . bucket , Key : incomingFd . replace ( / ^\/+ / , '' ) , //« remove any leading slashes Body : incomingFileStream , ContentType : mime . getType ( incomingFd ) //« advisory; makes things nicer in the S3 dashboard } ) , ( err , rawS3ResponseData ) => { if ( err ) { return done ( err ) ; } else { return done ( undefined , { rawS3ResponseData } ) ; } } ) ; //_∏_ s3ManagedUpload . on ( 'httpUploadProgress' , ( event ) => { // console.log('upload progress'); let written = _ . isNumber ( event . loaded ) ? event . loaded : 0 ; let total = _ . isNumber ( event . total ) ? event . total : undefined ; let handledSuccessfully = handleProgress ( _stripKeysWithUndefinedValues ( { name : incomingFileStream . filename || incomingFd , fd : incomingFd , written , total , percent : total ? ( written / total ) : undefined } ) ) ; if ( ! handledSuccessfully ) { s3ManagedUpload . abort ( ) ; } } ) ; //œ }
ƒ
ƒ