lib/s3-upload-stream.js
function () {
    // There is a possibility that the incoming stream was empty, therefore the MPU never started
    // and cannot be finalized.
    if (multipartUploadID) {
      cachedClient.completeMultipartUpload(
        {
          Bucket: destinationDetails.Bucket,
          Key: destinationDetails.Key,
          UploadId: multipartUploadID,
          MultipartUpload: {
            Parts: partIds
          }
        },
        function (err, result) {
          if (err)
            abortUpload('Failed to complete the multipart upload on S3: ' + JSON.stringify(err));
          else {
            // Emit both events for backwards compatibility, and to follow the spec.
            ws.emit('uploaded', result);
            ws.emit('finish', result);
            started = false;
          }
        }
      );
    }
  }
function () {
    // There is a possibility that the incoming stream was empty, therefore the MPU never started
    // and cannot be finalized.
    if (multipartUploadID) {
      cachedClient.completeMultipartUpload(
        {
          Bucket: destinationDetails.Bucket,
          Key: destinationDetails.Key,
          UploadId: multipartUploadID,
          MultipartUpload: {
            Parts: partIds
          }
        },
        function (err, result) {
          if (err)
            abortUpload('Failed to complete the multipart upload on S3: ' + JSON.stringify(err));
          else {
            // Emit both events for backwards compatibility, and to follow the spec.
            ws.emit('uploaded', result);
            ws.emit('finish', result);
            started = false;
          }
        }
      );
    }
  }
function ( ) { // There is a possibility that the incoming stream was empty, therefore the MPU never started // and cannot be finalized. if ( multipartUploadID ) { cachedClient . completeMultipartUpload ( { Bucket : destinationDetails . Bucket , Key : destinationDetails . Key , UploadId : multipartUploadID , MultipartUpload : { Parts : partIds } } , function ( err , result ) { if ( err ) abortUpload ( 'Failed to complete the multipart upload on S3: ' + JSON . stringify ( err ) ) ; else { // Emit both events for backwards compatibility, and to follow the spec. ws . emit ( 'uploaded' , result ) ; ws . emit ( 'finish' , result ) ; started = false ; } } ) ; } }
Turn all the individual parts we uploaded to S3 into a finalized upload.
Turn all the individual parts we uploaded to S3 into a finalized upload .