 
 class Uploader extends EventEmitter
   #FIXME: 0 records?
-  constructor: ({accessKey, secretKey, region, stream, objectName, objectParams, bucket, partSize, maxBufferSize, waitForPartAattempts}, @cb) ->
+  constructor: ({accessKey, secretKey, region, stream, objectName, objectParams, bucket, partSize, maxBufferSize, waitForPartAttempts, waitTime}, @cb) ->
     super()
     aws.config.update
       accessKeyId:     accessKey


    @maxBufferSize = maxBufferSize # TODO

    @waitForPartAattempts = waitForPartAattempts or 5

    if not @objectParams.Bucket then throw new Error "Bucket must be given"


            Key:      @objectParams.Key

          ,(err, data) =>
            if err
              return cb err

            parts = []
            for part in data?['Parts'] or []
              parts.push part.ETag

            hasAllParts = true

            #shouldn't happen
            if not parts.length
              hasAllParts = false

            notUploaded = []
            for partNumber, etag of @uploadedParts
              if not (etag in parts)
                hasAllParts = false
                notUploaded.push partNumber: partNumber, etag: etag

            if hasAllParts
              if not callbackCalled
                callbackCalled = true
                return cb()

            if checkPartsCounterInt > @waitForPartAttempts
              if not callbackCalled
                callbackCalled = true
                return cb new Error "Not all parts uploaded. Uploaded: #{JSON.stringify @uploadedParts}, Reported by listParts as uploaded: #{JSON.stringify data?['Parts']}"

        ), @waitTime
      ], (err) =>

        clearInterval checkPartsInterval

        @emit 'finishing'

        if err
          return @emit 'failed', err

        @getNewClient().completeMultipartUpload
          UploadId: @uploadId
