         chunk.progress = false
         chunk.finished = true
 
-        @uploadedParts[currentPartNumber] = data.ETag
+        @uploadedParts[currentPartNumber] = data?.ETag
 
         if err then @emit 'error', err
-        @emit 'uploaded', etag: data.ETag
+        @emit 'uploaded', etag: data?.ETag
 
-        next()
+        next err
 
     , (err) =>
+      if err then console.error 'Upload failed', err
       @pruneParts()
 
 

    @partNumber      = 1
    @parts           = []
    @uploadedParts   = {}
    @partSize        = partSize or 5242880 # 5MB
    @currentChunk    = new Buffer 0


    @on 'error', (err) => @failed = true

    @handleStream stream
    process.nextTick => @initiateTransfer()




class Uploader extends EventEmitter
  #FIXME: 0 records?
  constructor: ({accessKey, secretKey, region, stream, objectName, objectParams, bucket, partSize, maxBufferSize, verbose}, @cb) ->
    super()

    aws.config.update
      accessKeyId:     accessKey
      secretAccessKey: secretKey
