-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontroller.js
31 lines (28 loc) · 919 Bytes
/
controller.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Filename /tmp/tmp.js
var app = angular.module('upl', ['ngFileUpload']);
app.controller('myCtrl', function($scope, Upload) {
$scope.size = 32499;
$scope.result = null;
$scope.prcnt = 0;
$scope.run = function () {
var file = new Blob([new Uint8Array($scope.size)], {type: 'application/octet-stream'});
$scope.prcnt = 0;
Upload.upload({
url: '/upload',
data: {file: file}
}).then(
function (resp){
console.log('Success ' + resp.config.data.file.name + 'uploaded. Response: ' + resp.data);
$scope.result = resp.data;
},
function (resp) {
console.log('Error status: ' + resp.status);
$scope.result = resp.data;
},
function (evt) {
var progressPercentage = parseInt(100.0 * evt.loaded / evt.total);
console.log('progress: ' + progressPercentage + '% ' + evt.config.data.file.name);
$scope.prcnt = progressPercentage;
});
};
});