             @_disabled = false
             @_createInput()
 
-        _uploadS3: ({ file, filename, destFolder }) ->
+
+        _uploadS3: ({ file, filename, destFolder, signedUrl, uploadMethod, uploadUrl }) ->
+            return $http.put(
+                uploadUrl
+                file
+                headers: 'Content-Type': file.type
+            ) if signedUrl
+
             defer = $q.defer()
             awsS3 = @awscredentials
 

angular.module('cg.fileupload')
.factory 'cgFileUploadCtrl', ($timeout, $q) ->

    class cgFileUploadCtrl


            name = name.replace /[^a-zA-Z-_.0-9]/g, '_'
            _prefixRand = "#{ Math.floor(Math.random() * 10000) }-#{ Date.now() }"
            return "#{ _prefixRand }-#{ name }"

        _upload: ({ file, filename, destFolder, uploadUrl, uploadMethod, signedUrl }) ->
            @_disabled = true

            func = if @awscredentials or signedUrl then '_uploadS3' else '_uploadWorker'
            this[func]({
                file
                filename
                destFolder
                uploadUrl
                uploadMethod
                signedUrl
            }).then(
                (data) => @_loadHandler(data) # success
                (err) => @_errorHandler(err) # error
