             @_disabled = false
             @_createInput()
 
-
-        _setDestFolder: (destFolder) =>
-            @awscredentials.destFolder = destFolder
-
-
-        _uploadS3: (file, filename) ->
+        _uploadS3: ({ file, filename, destFolder }) ->
             defer = $q.defer()
             awsS3 = @awscredentials
 

            return unless file
            @_size = (file.size / Math.pow(1024, 2)).toFixed(2)
            @_mimetype = file.type
            @onUploadStart?(
                size: @_size
                filename: file.name
                progress: 0
            )

            @onBeforeUpload?(
                filename: file.name
                setDestFolder: @_setDestFolder
            )

            @_disabled = true

            func = if @awscredentials then '_uploadS3' else '_uploadWorker'
            filename = @_normalizeName(file.name)
            this[func](file, filename).then(
                (data) => @_loadHandler(data) # success
                (err) => @_errorHandler(err) # error
                (data) => @onProgress?(data) # notify
            )


    return cgFileUploadCtrl


            return defer.promise

        _uploadWorker: ({ file, filename }) ->
            defer = $q.defer()
            script = document.querySelectorAll('[src*="cg-file-upload.js"]')[0]
            workerUrl = new URL script.src.replace 'file-upload.js', 'file-upload-worker.js'
