 
         attempts = 0
         do retry = =>
-          if @__uploadDf.state() != 'pending'
+          if @apiDeferred.state() != 'pending'
             return
 
           attempts += 1

        @__rejectApi 'image'
        return

      @multipartStart().done (data) =>
        @uploadParts(data.parts).done =>
          @multipartComplete(data.uuid).done (data) =>
            @fileId = data.uuid
            @__handleFileData(data)
            @__completeUpload()
          .fail @__uploadDf.reject
        .fail @__uploadDf.reject
      .fail @__uploadDf.reject

    multipartStart: ->
      data =

        total = 0
        for loaded in progress
          total += loaded
        df.notify(total / @fileSize)

      df = $.Deferred()

