lib/s3-upload-stream.js
function (next) {

    // If this is the first part, and we're just starting,
    // but we have a multipartUploadID, then we're beginning
    // a resume and can fire the 'ready' event externally.
    if (multipartUploadID && !started)
      ws.emit('ready', multipartUploadID);

    started = true;

    if (pendingParts < concurrentPartThreshold) {
      // Has the MPU been created yet?
      if (multipartUploadID)
        upload(); // Upload the part immediately.
      else {
        e.once('ready', upload); // Wait until multipart upload is initialized.
        createMultipartUpload();
      }
    }
    else {
      // Block uploading (and receiving of more data) until we upload
      // some of the pending parts
      e.once('part', upload);
    }

    function upload() {

      // Pause/resume check #2 out of 2:
      //   Block queued up parts until resumption.
      if (paused)
        e.once('resume', uploadNow);
      else
        uploadNow();

      function uploadNow() {
        pendingParts++;
        flushPart(function (partDetails) {
          --pendingParts;
          e.emit('part'); // Internal event
          ws.emit('part', partDetails); // External event

          // if we're paused and this was the last outstanding part,
          // we can notify the caller that we're really paused now.
          if (paused && pendingParts === 0)
            notifyPaused();
        });
        next();
      }
    }
  }
function (next) {

    // If this is the first part, and we're just starting,
    // but we have a multipartUploadID, then we're beginning
    // a resume and can fire the 'ready' event externally.
    if (multipartUploadID && !started)
      ws.emit('ready', multipartUploadID);

    started = true;

    if (pendingParts < concurrentPartThreshold) {
      // Has the MPU been created yet?
      if (multipartUploadID)
        upload(); // Upload the part immediately.
      else {
        e.once('ready', upload); // Wait until multipart upload is initialized.
        createMultipartUpload();
      }
    }
    else {
      // Block uploading (and receiving of more data) until we upload
      // some of the pending parts
      e.once('part', upload);
    }

    function upload() {

      // Pause/resume check #2 out of 2:
      //   Block queued up parts until resumption.
      if (paused)
        e.once('resume', uploadNow);
      else
        uploadNow();

      function uploadNow() {
        pendingParts++;
        flushPart(function (partDetails) {
          --pendingParts;
          e.emit('part'); // Internal event
          ws.emit('part', partDetails); // External event

          // if we're paused and this was the last outstanding part,
          // we can notify the caller that we're really paused now.
          if (paused && pendingParts === 0)
            notifyPaused();
        });
        next();
      }
    }
  }
function ( next ) { // If this is the first part, and we're just starting, // but we have a multipartUploadID, then we're beginning // a resume and can fire the 'ready' event externally. if ( multipartUploadID && ! started ) ws . emit ( 'ready' , multipartUploadID ) ; started = true ; if ( pendingParts < concurrentPartThreshold ) { // Has the MPU been created yet? if ( multipartUploadID ) upload ( ) ; // Upload the part immediately. else { e . once ( 'ready' , upload ) ; // Wait until multipart upload is initialized. createMultipartUpload ( ) ; } } else { // Block uploading (and receiving of more data) until we upload // some of the pending parts e . once ( 'part' , upload ) ; } function upload ( ) { // Pause/resume check #2 out of 2: //   Block queued up parts until resumption. if ( paused ) e . once ( 'resume' , uploadNow ) ; else uploadNow ( ) ; function uploadNow ( ) { pendingParts ++ ; flushPart ( function ( partDetails ) { -- pendingParts ; e . emit ( 'part' ) ; // Internal event ws . emit ( 'part' , partDetails ) ; // External event // if we're paused and this was the last outstanding part, // we can notify the caller that we're really paused now. if ( paused && pendingParts === 0 ) notifyPaused ( ) ; } ) ; next ( ) ; } } }
Concurrently upload parts to S3.
Concurrently upload parts to S3 .