{"action":"created","issue":{"url":"https://api.github.com/repos/danialfarid/ng-file-upload/issues/1527","repository_url":"https://api.github.com/repos/danialfarid/ng-file-upload","labels_url":"https://api.github.com/repos/danialfarid/ng-file-upload/issues/1527/labels{/name}","comments_url":"https://api.github.com/repos/danialfarid/ng-file-upload/issues/1527/comments","events_url":"https://api.github.com/repos/danialfarid/ng-file-upload/issues/1527/events","html_url":"https://github.com/danialfarid/ng-file-upload/issues/1527","id":154417703,"number":1527,"title":"Why goes my progress bar to 100% before Upload finished?","user":{"login":"mitomm","id":15159289,"avatar_url":"https://avatars.githubusercontent.com/u/15159289?v=3","gravatar_id":"","url":"https://api.github.com/users/mitomm","html_url":"https://github.com/mitomm","followers_url":"https://api.github.com/users/mitomm/followers","following_url":"https://api.github.com/users/mitomm/following{/other_user}","gists_url":"https://api.github.com/users/mitomm/gists{/gist_id}","starred_url":"https://api.github.com/users/mitomm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitomm/subscriptions","organizations_url":"https://api.github.com/users/mitomm/orgs","repos_url":"https://api.github.com/users/mitomm/repos","events_url":"https://api.github.com/users/mitomm/events{/privacy}","received_events_url":"https://api.github.com/users/mitomm/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-05-12T07:44:49Z","updated_at":"2016-05-12T10:25:04Z","closed_at":null,"body":"Hi there,\r\n\r\nthanks for the great plugin.\r\n\r\nHowever, somehow I cannot get the progress bar to work properly. Whatever I upload and unrelated to how long the upload really takes, the progress bar very quickly jumps to 100%.\r\n\r\nMy basic code looks as follows:\r\n\r\n```\r\n settingsApp.controller('imageUploadController', function($scope, Upload, $uibModalInstance, $timeout, backendUploadPath, cropShape, cropRatio, imageWidth){\r\n\r\n\tvar upload;\r\n\t\t\r\n\t$scope.genericUpload = function (croppedDataUrl, imageName) {\r\n\t\tthis.upload = Upload.upload({\r\n\t\t    url: backendUploadPath,\r\n\t\t    data: {\r\n\t\t        file: Upload.dataUrltoBlob(croppedDataUrl),\r\n\t\t\t\tname: imageName //only used to get ending of filename (.jpeg, etc...)\r\n\t\t    },\r\n\t\t}).then(function (response) {\r\n\t\t\t// file is uploaded successfully\r\n\t\t    $timeout(function () {\r\n\t\t        $scope.result = response.data;  \r\n\t\t        $uibModalInstance.close({\"tempImgData\":croppedDataUrl,\"insertID\":response.data.insertID});\t        \r\n\t\t    });\r\n\t\t}, function (response) {\r\n\t\t\t// handle error\r\n\t\t\tif (response.status > 0) {\r\n\t\t\t\t$scope.errorMsg = response.status + ': ' + response.data;\r\n\t\t\t}\r\n\t\t}, function (evt) {\r\n  \t\t\t// progress notify\r\n  \t\t\tif ($scope.errorMsg) {\r\n  \t\t\t\treturn\r\n  \t\t\t}\r\n\t\t    $scope.progress = parseInt(100.0 * evt.loaded / evt.total);    \r\n\t\t});\r\n\t}\r\n     .....\r\n}\r\n```\r\n\r\nLogging $scope.progress prints numbers from 0 up to 100 in steps of 9 (e.g. 8, 17, 26, 35,..) and reaches 100 long before upload is finished?\r\n\r\nAny idea on what I'm doing wrong?\r\n\r\nAny help is greatly appreciated."},"comment":{"url":"https://api.github.com/repos/danialfarid/ng-file-upload/issues/comments/218718377","html_url":"https://github.com/danialfarid/ng-file-upload/issues/1527#issuecomment-218718377","issue_url":"https://api.github.com/repos/danialfarid/ng-file-upload/issues/1527","id":218718377,"user":{"login":"mitomm","id":15159289,"avatar_url":"https://avatars.githubusercontent.com/u/15159289?v=3","gravatar_id":"","url":"https://api.github.com/users/mitomm","html_url":"https://github.com/mitomm","followers_url":"https://api.github.com/users/mitomm/followers","following_url":"https://api.github.com/users/mitomm/following{/other_user}","gists_url":"https://api.github.com/users/mitomm/gists{/gist_id}","starred_url":"https://api.github.com/users/mitomm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitomm/subscriptions","organizations_url":"https://api.github.com/users/mitomm/orgs","repos_url":"https://api.github.com/users/mitomm/repos","events_url":"https://api.github.com/users/mitomm/events{/privacy}","received_events_url":"https://api.github.com/users/mitomm/received_events","type":"User","site_admin":false},"created_at":"2016-05-12T10:25:04Z","updated_at":"2016-05-12T10:25:04Z","body":"I assume it based on multiple reasons:\r\n1. the success callback\r\n```\r\n.then(function (response) {\r\n            // file is uploaded successfully\r\n            $timeout(function () {\r\n                $scope.result = response.data;  \r\n                $uibModalInstance.close({\"tempImgData\":croppedDataUrl,\"insertID\":response.data.insertID});          \r\n            });\r\n        }, ....\r\n```\r\nis getting called about a second later than `$scope.progress` reaches 100\r\n2. I intentionally tried it with a very slow internet connection, but still, the progress reaches 100 in a couple ms which regarding the slow connection cannot be possible.\r\n\r\nDo I have to handle the progress in the backend (with Node) somehow?"}}